[DB-SIG] DB-API unittests
Carsten Haese
carsten at uniqsys.com
Thu Dec 1 14:36:27 CET 2005
On Thu, 2005-12-01 at 05:07, M.-A. Lemburg wrote:
> Andrew Chambers wrote:
> > - Evidently there is ambiguity about the way that dates should be entered.
> > pgdb - curs.execute("select '%s'" % Date(2005, 01, 01))
> > psycopg - curs.execute("select %s" % Date(2005, 01, 01))
> > Don't know about the others - I don't have them installed
>
> psycopg is doing the right thing here - whatever Date() returns
> should be directly usable with the %s parameter marker.
Since nobody else seems to have noticed this, I'll point this out: The
OP is not using %s as a parameter marker, since he is not passing a
parameter tuple. He is using the %-operator to build a query as if
DB-API didn't have parametrized queries.
The correct way of course is curs.execute("select %s", (Date(2005, 01,
01),) ) which should work on any DB-API implementation that uses this
particular marker style. IMHO this parameter style should be deprecated
because it makes it way too easy to make -- and overlook -- this kind of
mistake.
-Carsten Haese
More information about the DB-SIG
mailing list