Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
20773 Lượt xem

Hello I try to use the module import_odbc to to import data from an MSSQL-Server to OpenERP. I created a data source successfully but always get the following error when I press the button "Run import"

ProgrammingError: ('The SQL contains 0 parameter markers, but 1 parameters were supplied', 'HY000')

Does someone know how to solve this problem? I made tests with the following sample-script from the module:


SELECT distinct [SUPPLIER_CODE] as "ref", [SUPPLIER_NAME] as "name" , 1 as "is_supplier" , [INFO] as "comment" FROM T_SUPPLIERS WHERE INACTIVE_DATE IS NULL and DATE_CHANGED >= %(sync)s


How should this statement be modified to get rid of that error?

Thanks Rene

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

After making the following changes in import_odbc.py it works:

line 148: change "params = {'sync': sync}" to "params = sync" line 149: change "obj.sql_source" to "obj.sql_source.encode('utf-8')"

But now I have still a problem concerning the schedular. When I activate a schedular for a connection I always get the following error:


2013-05-10 07:30:11,484 13963 ERROR test openerp.addons.base.ir.ir_cron: Call of self.pool.get('import.odbc.dbtable').import_run(cr, uid, *()) failed in Job 15 Traceback (most recent call last): File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_cron.py", line 136, in _callback method(cr, uid, *args) File "/home/erp/openobject-extension/import_odbc/import_odbc.py", line 120, in import_run actions = self.read(cr, uid, ids, ['id', 'exec_order']) File "/opt/openerp/v7/server/openerp/osv/orm.py", line 3603, in read select = map(lambda x: isinstance(x, dict) and x['id'] or x, select) TypeError: argument 2 to map() must support iteration


Does someone know how to solve this?

Ảnh đại diện
Huỷ bỏ

Can you confirm if change in line 148 is necessary ?

Tác giả

yes, change in line 148 is necessary, otherwise there is always another error-message "('Python type dict not supported. param=1', 'HY097')"

Câu trả lời hay nhất

I believe that the sync date parameter is inserted using a ?.

Try:

SELECT distinct [SUPPLIER_CODE] as "ref", [SUPPLIER_NAME] as "name" , 1 as "is_supplier" , [INFO] as "comment" FROM T_SUPPLIERS WHERE INACTIVE_DATE IS NULL and DATE_CHANGED >= ?
Ảnh đại diện
Huỷ bỏ
Tác giả

this I already tried but the error remains the same. I tried also with two different drivers (FreeTDS and Microsoft ODBC Driver) but always the same problem....

Does it work without the DATE_CHANGED >= ? part?

Tác giả

unfortunytely this does also not work, even if there is no parameter marker at all. When I use the Microsoft-Driver I always get the following error, where the sql-statement is also shown correctly, but the parameter marker is not recognized: ProgrammingError: (ProgrammingError) ('The SQL contains 0 parameter markers, but 1 parameters were supplied', 'HY000') u'SELECT distinct [SUPPLIER_CODE] as "ref", [SUPPLIER_NAME] as "name" , 1 as "is_supplier" , [INFO] as "comment" FROM T_SUPPLIERS WHERE INACTIVE_DATE IS NULL and DATE_CHANGED >= ?' {'sync': datetime.datetime(2013, 4, 17, 20, 58, 31)}

Tác giả

In my opinion it must be a problem in the model import_odbc when used in v7. Did someone already try if import_odbc is also working in v7? Can someone help?