ibec_ExtractMetadata don't extract tables like "TaSomeData". IBExpert. IBEScript Firebird 2.1 - firebird2.1

I have a problem with the command ibec_ExtractMetadata from IBEScript(ibeblock). In my Database most tables have names in InfixCaps like "TaActions", "TaDiscountSystem" etc.
If I use ibec_ExtractMetadata with tables in UpperCase - all is well:
ibec_ExtractMetadata(OtdelDB, 'd:\DC_Otdel.sql',
'Domains=NONE; Tables=ACCESSGROUPS; Views=NONE; Triggers=NONE;
Procedures=NONE; Generators=NONE;
Exceptions=NONE; UDFs=NONE; Roles=NONE;DataTables=ACCESSGROUPS;
ExtractBLOBs;UseReinsert; CommitAfter=1000', cbb);
But if I want to extract metadata from table "TaDiscountSystem":
ibec_ExtractMetadata(OtdelDB, 'd:\DC_Otdel.sql',
'AlwaysQuoteIdents; Domains=NONE; Tables=NONE; Views=NONE; Triggers=NONE;
Procedures=NONE; Generators=NONE;
Exceptions=NONE; UDFs=NONE; Roles=NONE;DataTables=TalmbDiscountSystem;
ExtractBLOBs; UseReinsert; CommitAfter=1000', cbb);
The script output is empty.

Related

convert postgresql table to xml

I have a postgresql table with following columns
classificazione_dpr_412,superficie_utile_riscaldata, classe_energetica, epgl_n_ren, tipo_intervento_1, tipo_intervento_2, tipo_intervento_3, superficie_disperdente, rapporto_asol_asup, tipo_impianto, anno_installazione_generatore, combustibile, potenza_nominale, efficienza_media_stagionale, ep_nren_clim_inv, ep_nren_acs, ep_nren_illuminazione, comune, regione, ep_nren_standard_rif
and need a postgresql query to transform it into following xml file.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ape2015 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<datiGenerali>
<classificazioneDPR412>"classificazione_dpr_412"</classificazioneDPR412>
<datiIdentificativi>
<superficieUtileRiscaldata> "superficie_utile_riscaldata"</superficieUtileRiscaldata>
</datiIdentificativi>
</datiGenerali>
<prestazioneGlobale>
<prestazioneEnergeticaGlobale>
<classificazione>
<classeEnergetica>"classe_energetica"</classeEnergetica>
<epglnren> "epgl_n_ren"</epglnren>
</classificazione>
</prestazioneEnergeticaGlobale>
</prestazioneGlobale>
<raccomandazioni>
<interventoRaccomandato>
<codice>"tipo_intervento_1"</codice>
<tipoInterventoRaccomandato>"tipo_intervento_1"</tipoInterventoRaccomandato>
</interventoRaccomandato>
<interventoRaccomandato>
<codice>"tipo_intervento_2"</codice>
<tipoInterventoRaccomandato>"tipo_intervento_2"</tipoInterventoRaccomandato>
</interventoRaccomandato>
<interventoRaccomandato>
<codice>"tipo_intervento_3"</codice>
<tipoInterventoRaccomandato>"tipo_intervento_3"</tipoInterventoRaccomandato>
</interventoRaccomandato>
</raccomandazioni>
<datiFabbricato>
<superficieDisperdente> "superficie_disperdente"</superficieDisperdente>
<rapportoAsolAsupUtile> "rapporto_asol_asup"</rapportoAsolAsupUtile>
</datiFabbricato>
<datiImpianti>
<climatizzazioneInvernale>
<impianto>
<tipoImpianto>"tipo_impianto"</tipoImpianto>
<annoInstallazione>"anno_installazione_generatore"</annoInstallazione>
<vettoriEnergeticiUtilizzati>
<vettore>"combustibile"</vettore>
</vettoriEnergeticiUtilizzati>
<potenzaNominale> "potenza_nominale"</potenzaNominale>
</impianto>
<efficienza> "efficienza_media_stagionale"</efficienza>
<prestazione>
<epnren> "ep_nren_clim_inv"</epnren>
</prestazione>
</climatizzazioneInvernale>
<produzioneACS>
<prestazione>
<epnren> "ep_nren_acs"</epnren>
</prestazione>
</produzioneACS>
<illuminazione>
<prestazione>
<epnren> "ep_nren_illuminazione"</epnren>
</prestazione>
</illuminazione>
</datiImpianti>
<datiExtra>
<comune>"comune"</comune>
<regione>"regione"</regione>
<EPglnrenRifStandard> "ep_nren_standard_rif"</EPglnrenRifStandard>
</datiExtra>
</ape2015>
I need a proper postgresql query to transform postgresql table into xml file.
If you are executing query directly in tools or console, you can use tools like DataGrip which will give you an option to export files in various options including XML.
If you are executing a query inside an application, it should be very easy to convert JSON or Object data to XML. You do not need SQL to convert data into XML file.

You cannot define a correlation name 'links' more than once

Hello and thank you in advanced.
I have an error in product page of Magento 2.3:
You cannot define a correlation name 'links' more than once
trace:
{"0":"You cannot define a correlation name 'links' more than
once","1":"#0
/home/buybionette/public_html/vendor/magento/framework/DB/Select.php(298):
Zend_Db_Select->_join('inner join', Array, 'links.linked_pr...',
Array, NULL)\n#1
/home/buybionette/public_html/vendor/magento/zendframework1/library/Zend/Db/Select.php(357):
Magento\Framework\DB\Select->_join('inner join', Array,
'links.linked_pr...', Array, NULL)\n#2
/home/buybionette/public_html/vendor/magento/zendframework1/library/Zend/Db/Select.php(336):
Zend_Db_Select->joinInner(Array, 'links.linked_pr...', Array,
NULL)\n#3
/home/buybionette/public_html/vendor/magento/module-catalog/Model/ResourceModel/Product/Link/Product/Collection.php(230):
Zend_Db_Select->join(Array, 'links.linked_pr...', Array)\n#4
/home/buybionette/public_html/vendor/magento/module-catalog/Model/ResourceModel/Product/Link/Product/Collection.php(184):
Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection->_joinLinks()\n#5
/home/buybionette/public_html/vendor/magento/module-eav/Model/Entity/Collection/AbstractCollection.php(917):
Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection->_beforeLoad()\n#6
/home/buybionette/public_html/vendor/magento/module-catalog/Model/ResourceModel/Product/Collection.php(790):
Magento\Eav\Model\Entity\Collection\AbstractCollection->load(false,
false)\n#7
/home/buybionette/public_html/vendor/magento/framework/Interception/Interceptor.php(58):
Magento\Catalog\Model\ResourceModel\Product\Collection->load(false,
false)\n#8
/home/buybionette/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection\Interceptor->___callParent('load',
Array)\n#9
/home/buybionette/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection\Interceptor->Magento\Framework\Interception\{closure}()\n#10
/home/buybionette/public_html/generated/code/Magento/Catalog/Model/ResourceModel/Product/Link/Product/Collection/Interceptor.php(390):
Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection\Interceptor->___callPlugins('load',
Array, Array)\n#11
/home/buybionette/public_html/vendor/magento/framework/Data/Collection.php(832):
Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection\Interceptor->load()\n#12
/home/buybionette/public_html/generated/code/Magento/Catalog/Model/ResourceModel/Product/Link/Product/Collection/Interceptor.php(1961):
Magento\Framework\Data\Collection->getIterator()\n#13
/home/buybionette/public_html/vendor/magento/module-catalog/Block/Product/ProductList/Related.php(137):
Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection\Interceptor->getIterator()\n#14
/home/buybionette/public_html/generated/code/Magento/Catalog/Block/Product/ProductList/Related/Interceptor.php(37):
Magento\Catalog\Block\Product\ProductList\Related->getIdentities()\n#15
/home/buybionette/public_html/vendor/magento/module-page-cache/Model/Layout/LayoutPlugin.php(71):
Magento\Catalog\Block\Product\ProductList\Related\Interceptor->getIdentities()\n#16
/home/buybionette/public_html/vendor/magento/framework/Interception/Interceptor.php(146): Magento\PageCache\Model\Layout\LayoutPlugin->afterGetOutput(Object(Magento\Framework\View\Layout\Interceptor), '\n Magento\Framework\Interception\{closure}()\n#18
/home/buybionette/public_html/generated/code/Magento/Framework/View/Layout/Interceptor.php(494):
Magento\Framework\View\Layout\Interceptor->___callPlugins('getOutput',
Array, Array)\n#19
/home/buybionette/public_html/vendor/magento/framework/View/Result/Page.php(258):
Magento\Framework\View\Layout\Interceptor->getOutput()\n#20
/home/buybionette/public_html/vendor/magento/framework/View/Result/Layout.php(171):
Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor))\n#21
/home/buybionette/public_html/vendor/magento/framework/Interception/Interceptor.php(58):
Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))\n#22
/home/buybionette/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult',
Array)\n#23
/home/buybionette/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))\n#24
/home/buybionette/public_html/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(130):
Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult',
Array, Array)\n#25
/home/buybionette/public_html/vendor/magento/framework/App/Http.php(139):
Magento\Framework\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))\n#26
/home/buybionette/public_html/generated/code/Magento/Framework/App/Http/Interceptor.php(24):
Magento\Framework\App\Http->launch()\n#27
/home/buybionette/public_html/vendor/magento/framework/App/Bootstrap.php(258):
Magento\Framework\App\Http\Interceptor->launch()\n#28
/home/buybionette/public_html/index.php(40):
Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#29
{main}","url":"/bionette.html","script_name":"/index.php"}
This is a very basic site, no special modules or themes.
Thank you, Eran
https://community.magento.com/t5/Magento-2-x-Technical-Issues/Magento-2-3-Inventory-stock-1-doesn-t-Exist-On-Magento-2-3/td-p/120679
By PankajS_Magento
Here is the command to run in DB SQL make sure to update dbname.
CREATE ALGORITHM = UNDEFINED SQL SECURITY
INVOKER VIEW `inventory_stock_1` AS
select distinct `legacy_stock_status`.`product_id` AS `product_id`,
`legacy_stock_status`.`website_id` AS `website_id`,
`legacy_stock_status`.`stock_id` AS `stock_id`,
`legacy_stock_status`.`qty` AS `quantity`,
`legacy_stock_status`.`stock_status` AS `is_salable`,
`product`.`sku` AS `sku`
from (`dbname`.`cataloginventory_stock_status` `legacy_stock_status`
join `dbname`.`catalog_product_entity` `product`
on ((`legacy_stock_status`.`product_id` = `product`.`entity_id`)));

Adding columns to a Web2py table in a form

In my web2py application, in the controller I read from an external DB the names of students I want to take a register for. I loop through the resulting list adding the list elements to a new list.
for student in pupils_query:
attendance_list.insert(counter, [student[0], student[1], student[2], student[3]])
counter += 1
counter = 0
Then for each student I read their attendance codes for the day so far from another table, and append them to attendance_list:
for attendance_code in attendance_result:
attendance_list[counter].append(attendance_code)
Now, I'm going to want to make a form from all this, using a table which will show each students' attendance code in a text input (so they can be updated if wrong), then have a dropdown for input of the current lesson code.
I'm using a FORM and TABLE helper to create the table in the form:
form=FORM(TABLE(*[TR(*rows) for rows in attendance_list]))
but can't seem to be able to add a new 'row' form item with something like:
select = "SELECT("+ main_reg_list +")"
attendance_list[counter].append(select)
where main_reg_list is dictionary of acceptable attendance codes (or of course, any other form input element).
In summary, I'm stuck adding new TDs to a table made with a TABLE helper from a list of lists. I bet I'm not the first person to overcome this problem.
I am still not clear about what you want. I think you want table of student information and in one column you want dropdown. Something similat to following image
Above form is created from following code.
I hope following code will help you:
# controller/default.py
def index():
# Dummy attendance list, list after appending attendance code
attendance_list = [['stud_id_1', 'first_name_1', 'last_name_1', 'attendance_code_1'],
['stud_id_2', 'first_name_2', 'last_name_2', 'attendance_code_2'],
['stud_id_3', 'first_name_3', 'last_name_3', 'attendance_code_5'],
['stud_id_4', 'first_name_4', 'last_name_4', 'attendance_code_4']]
possible_att_code = ['attendance_code_1', 'attendance_code_2', 'attendance_code_3', 'attendance_code_4', 'attendance_code_5']
# initialise form_rows with Table heading
form_rows = [THEAD(TR(TH('ID'), TH('First Name'), TH('Last Name'), TH('Attendence Code')))]
for attendance in attendance_list:
attendance_code_dropdown = _get_dropdown(attendance[0], attendance[3], possible_att_code)
td_list = [TD(attendance[0]), TD(attendance[1]), TD(attendance[2]),
TD(attendance_code_dropdown)]
table_row = TR(td_list, _id='row_' + attendance[0])
form_rows.append(table_row)
# Form submit button
form_rows.append(TR(INPUT(_type='submit')))
form = FORM(TABLE(*form_rows), _name='student_attendance',
_id='student_attendance')
if form.accepts(request, session):
# Write code to update record
pass
return dict(form=form)
def _get_dropdown(stud_id, att_code, possible_att_code):
option_list = []
for pac in possible_att_code:
if pac == att_code:
option_list.append(OPTION(pac, _value=pac, _selected='selected'))
else:
option_list.append(OPTION(pac, _value=pac))
return SELECT(*option_list, _name=stud_id)
<!-- views/default/index.html -->
{{extend 'layout.html'}}
{{=form}}
Are my assumptions correct? or you want any thing else? Comment if didn't understood code.

Dumping clustering result with vectors names

I have created my Vectors as described in this question and have run mahout kmeans on the data.
Since I'm using Mahout 0.7, the clusterdump command didn't work as described in Mahout in Action, but I got it to work like this:
export HADOOP_CLASSPATH=/path/to/mahout-distribution-0.7/core/target/mahout-core-0.7-job.jar:/path/to/mahout-distribution-0.7/integration/target/mahout-integration-0.7.jar
hadoop jar core/target/mahout-core-0.7-job.jar org.apache.mahout.utils.clustering.ClusterDumper -i /clustering/out/clusters-20-final -o textout -of TEXT
and I am getting lines like this one:
VL-1383471{n=192 c=[0.180, -0.087, 0.281, 0.512, 0.678, 1.833, 2.613, 0.313, 0.226, 1.023, 0.229, -0.104, -0.461, -0.553, -0.318, 0.315, 0.658, 0.245, 0.635, 0.220, 0.660, 0.193, 0.277, -0.182, 0.497, 0.346, 0.658, 0.660, 0.191, 0.660, 0.636, 0.018, 0.519, 0.335, 0.535, 0.008, -0.028, 0.461, 0.229, 0.287, 0.619, 0.509, 0.566, 0.389, -0.075, -0.180, -0.461, 0.381, -0.108, 0.126, -0.728] r=[0.983, 0.890, 0.384, 0.823, 0.702, 0.000, 0.000, 1.132, 0.605, 0.979, 0.897, 0.862, 0.438, 0.546, 0.390, 0.171, 0.257, 0.234, 0.251, 0.106, 0.257, 0.093, 0.929, 0.077, 0.204, 0.218, 0.257, 0.257, 0.258, 0.257, 0.249, 0.112, 0.217, 0.157, 0.284, 0.197, 0.228, 0.229, 0.323, 0.401, 0.248, 0.217, 0.269, 1.002, 0.819, 0.706, 0.412, 0.964, 0.787, 0.872, 0.172]}
which is not yet useful to me, since I need the names of my vectors in each cluster.
I saw that for text documents a dictionary file is created. How would I create a dictionary for my data?
Also, using -of CSV gives me an empty file, am I doing something wrong?
Another attempt I took was to directly access the cluster-20-final/part-m-00000 file, like it's done in listing 7.2 of Mahout in Action. Turns out it doesn't contain WeightedVectorWritable but ClusterWritable, from which I can get the Cluster instance but not any actual contained Vector.
A bit late, but this might help someone somewhere, sometime.
When running
KMeansDriver.run(input, clustersIn, outputPath, measure, convergenceDelta, maxIterations, true, 0.0, false);
One of the outputs was a directory called clusteredPoints. There is a part file there with all the clustered vectors by cluster. This means that something like this
IntWritable key = new IntWritable();
WeightedVectorWritable value = new WeightedVectorWritable();
Path clusteredPoints = new Path(output + "/" + Cluster.CLUSTERED_POINTS_DIR + "/part-m-00000");
FileSystem fs = FileSystem.get(clusteredPoints.toUri(), new Configuration());
try (SequenceFile.Reader reader = new SequenceFile.Reader(fs, clusteredPoints, fs.getConf())) {
while (reader.next(key, value)) {
// Do something useful here
((NamedVector) value.getVector()).getName();
}
} catch (Throwable t) {
throw t;
}
seems to do the trick. Using something like this, I was able to get a good sense of what was clustered where when running my tests with k-means clustering and Mahout.
I was using Mahout 0.8 when I did this.
(a really late answer, but since I just spent a day figuring this out thought I would share it)
What you are missing is the dictionary of Vector Dimension name to its index.
This dictionary will be used by clusterdump to give you the names of the different dimensions in the vector.
When you run clusterdump, you can specify two additional flags:
d: dictionary file
dt: type of the dictionary file (text|sequencefile)
Here is a sample invocation:
mahout clusterdump -i clusteringExperiment/exp1/initialCentroids/clusters-0-final -d clusteringExperiment/dictionary/vectorDimensions -dt sequencefile
and your output will look something like:
VL-0{n=185 c=[A:0.006, G:0.550, M:0.011, O:0.026, S:0.000, T:0.072, U:0.096, V:0.010] r=[A:0.029, G:0.176, M:0.043, O:0.054, S:0.001, T:0.098, U:0.113, V:0.035]}
Note that the dictionary is a simple key value file, where the key is the category name (a string), and the value is the numerical index.

Emoticons from iPhone to Python/Django

I'm trying to save comments from an iPhone app that may and nowadays most likely will include emoticons. No matter what I do, I can't save the emoticons to the MySQL database ... Constant Unicode errors.
Python 2.6.5
Django 1.2.1
MySQL database (set to utf8 character set for tables and rows)
Saving the data to a VARCHAR(255) field
The error I keep receiving is:
Incorrect string value: '\xF0\x9F\x97\xBC \xF0...' for column 'body' at row 1
The string I'm passing into the database is:
test_txt = u"Emoji - \U0001f5fc \U0001f60c \U0001f47b ...".encode('utf-8')
Update: Here's the model I'm using:
class ItemComment(db.Model):
item = db.ForeignKey(Item)
user = db.ForeignKey(Profile)
body = db.CharField(max_length=255, blank=True, null=True)
active = db.BooleanField(default=True)
date_added = db.DateTimeField(auto_now_add=True)
def __unicode__(self):
return "%s" % (self.item)
The odd thing is, if I try and pass this to a field that I've created in MySQL and not Django models.py it works fine. But as soon as I register the field in Django models it dies. Is there another way to store these perhaps?
Any ideas would be amazing.
I could not be more stuck on this ...
Update 2: Tracking it in Terminal using the following UPDATE statement (notice the U0001f5fc)
UPDATE 'table' SET 'body' = '🗼', WHERE 'table'.'id' = 1 ; args=(u'\U0001f5fc')
Using as hardcore as I can get to pass the value:
force_unicode(smart_str(value), encoding='utf-8', strings_only=False, errors='ignore')
But the error still throws:
_mysql_exceptions.Warning: Incorrect string value: '\xF0\x9F\x97\xBC' for column 'body' at row 1
Totally lost!!!
Cheers,
Change charset utf8mb4 for MySQL server (version 5.5.3 later)
In my.ini (my.cnf)
[mysqld]
character_set_server = utf8mb4
collation-server = utf8mb4_unicode_ci
or SQL query
SET NAMES 'utf8mb4';
see also http://dev.mysql.com/doc/refman/5.5/en/charset-connection.html
or deletes the character to do it.
python
import re
# emoji_text is unicode
no_emoji_text = re.sub('[\xF0-\xF7][\x80-\xBF][\x80-\xBF][\x80-\xBF]', '', str(emoji_text))
Thank you.
See also
MySQL throws Incorrect string value error
I use Django 1.11 and following setting.py and the create sql can store emoji well,
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'db_name',
'USER': 'db_user',
'PASSWORD': 'your_password',
'OPTIONS': {'charset': 'utf8mb4'}, # note here!!!
}
}
The sql come from this answer,
CREATE DATABASE db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;