DB-API corner case (psycopg2)
M.-A. Lemburg
mal at egenix.com
Fri Aug 1 10:40:16 EDT 2008
On 2008-08-01 15:44, Thomas Guettler wrote:
> Hi,
>
> I discovered this:
>
> import psycopg2
> connection=psycopg2.connect("dbname='...' user='...'")
> cursor=connection.cursor()
> cursor.execute('''SELECT '%' ''') # Does not fail
> cursor.execute('''SELECT '%' ''', ()) # Does fail
>
> Traceback (most recent call last):
> File "/localhome/modw/tmp/t.py", line 5, in <module>
> cursor.execute('''SELECT '%' ''', ()) # Does fail
> IndexError: tuple index out of range
>
> Is this a bug in psycopg2?
>
> How do other PEP 249 implementation behave?
This depends a lot on the database backend. Some might
complain about the use of an incomplete binding parameter
marker '%' and issue a ProgrammingError even if you don't
pass in any binding parameters (to inform you of the possible
bug in your application).
However, "'%'" may also be perfectly valid SQL when used without
binding parameters, so it's not clear whether this case should
always raise an exception.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Aug 01 2008)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the Python-list
mailing list