iheanyi / ibm-db

Automatically exported from code.google.com/p/ibm-db
0 stars 0 forks source link

Exception executing query when ibm_db_dbi.paramstyle = 'format' #155

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Queries can not be formatted using 'format' paramstyle

>>> import ibm_db_dbi
>>> ibm_db_dbi.paramstyle
'qmark'
>>> ibm_db_dbi.paramstyle = 'format'
>>> conn = ibm_db_dbi.connect("db2")
>>> cursor=conn.cursor()
>>> q = 'SELECT col1,col2 FROM test WHERE col0 = %s'
>>> cursor.execute(q, (1819043,))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib64/python2.6/site-packages/ibm_db-2.0.4.1-py2.6-linux-x86_64-SP3.egg/ibm_db_dbi.py", line 1331, in execute
    self._set_cursor_helper()
  File "/usr/local/lib64/python2.6/site-packages/ibm_db-2.0.4.1-py2.6-linux-x86_64-SP3.egg/ibm_db_dbi.py", line 1214, in _set_cursor_helper
    raise self.messages[len(self.messages) - 1]
ibm_db_dbi.ProgrammingError: ibm_db_dbi::ProgrammingError: SQLNumResultCols 
failed: [IBM][CLI Driver][DB2/LINUXX8664] SQL0104N  An unexpected token "=" was 
found following "test WHERE col0".  Expected tokens may include:  
"<interval_qualifier>".  SQLSTATE=42601 SQLCODE=-104

Original issue reported on code.google.com by south.mi...@gmail.com on 12 Jun 2014 at 3:05

GoogleCodeExporter commented 9 years ago
The above exception is expected one since it is not supported.

currently ibm_db_dbi only supports qmark parameter style. 

Original comment by rahul.pr...@in.ibm.com on 13 Jun 2014 at 6:41

GoogleCodeExporter commented 9 years ago
Thanks for the answer. The module could issue a warning 'not
implemented' in case it's set to something different than 'qmark' and
it should be documented in the code and the README file.

Code
=====
# Module globals
apilevel = '2.0'
threadsafety = 0
# only qmark is currently supported
paramstyle = 'qmark'

README
=======
Known Limitations for the Python wrapper

Original comment by south.mi...@gmail.com on 13 Jun 2014 at 7:14