Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

How to solve error "missing parameter marker" in module import_odbc?

By
René
on 4/18/13, 9:21 AM 3,829 views

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

0
René
On 4/19/13, 6:13 AM

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?

Can you confirm if change in line 148 is necessary ?

Daniel Reis
on 5/3/13, 9:51 AM

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

René
on 5/3/13, 4:37 PM
0

Daniel Reis

--Daniel Reis--
3436
| 6 7 9
Lisbon, Portugal
--Daniel Reis--

Author of the "Odoo Development Essentials" book.

Applications Manager at Securitas Portugal

Github: https://github.com/dreispt

Twitter; @reis_pt


Daniel Reis
On 4/18/13, 11:34 AM

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 >= ?

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....

René
on 4/18/13, 12:09 PM

Does it work without the DATE_CHANGED >= ? part?

Daniel Reis
on 4/19/13, 6:51 AM

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)}

René
on 4/19/13, 9:53 AM

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?

René
on 4/22/13, 7:10 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/18/13, 9:21 AM
Seen: 3829 times
Last updated: 3/16/15, 8:10 AM