Problem with bound parameters

From: charlie clark <charlie(at)begeistert(dot)org>
To: pgsql-odbc(at)postgresql(dot)org
Cc: info(at)egenix(dot)com
Subject: Problem with bound parameters
Date: 2005-05-11 15:14:45
Message-ID: opsql9yvntyt02yl@mail.isis.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Dear all,

I've hit upon a problem using bound parameters with pgsql-ODBC and strings
containing newlines ("\n"). I'm using PostgreSQL 8.0 rc1 and pgsql-ODBC
8.0.01.01 with Python 2.3 and mxODBC 1.08. It looks like the parameter is
being incorrectly quoted by the pgODBC driver.

This is from the command line

problem = """The partition you have selected is resizable, the installer
has chosen a reasonable size for splitting the available space.

You may select your own size by dragging the splitter, or typing in a size
in Megabytes.

You may also choose to use the entire partition for ZETA."""
>>> c.execute("""SELECT content FROM localekit
INNER JOIN localekit_attributes AS attr ON
(attr.id = localekit.id_attribute)
WHERE
locale = 'enUS'
AND attribute = ?
AND application = ?""", (problem, 'Installer'))

Traceback (most recent call last):
File "<pyshell#22>", line 1, in -toplevel-
c.execute("""SELECT content FROM localekit
ProgrammingError: ('HY000', 7, 'ERROR: type "lo" does not exist', 5898)
>>> c.execute("""SELECT content FROM localekit
INNER JOIN localekit_attributes AS attr ON
(attr.id = localekit.id_attribute)
WHERE
locale = 'enUS'
AND attribute = '%s'
AND application = '%s'""" %(problem, 'Installer'))

The first example raises the error for the incorrect type:
conn=36387816, query='select oid from pg_type where typname='lo''
[ fetched 0 rows ]

Which means that the statement is being corrupted somehow.

In the second example the quoting is done directly in Python and no error
is raised.

Is it not advisable to use bound parameters with pgsql-ODBC?

Thanks for any help

Charlie

--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D-40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226

Browse pgsql-odbc by date

  From Date Subject
Next Message Joel Fradkin 2005-05-11 16:43:43 encoding
Previous Message Patrick.FICHE 2005-05-11 11:38:14 PsqlODBC / Solaris 10