[DB-SIG] any 2.0-compliant packages for postgresql?

Federico Di Gregorio fog@mixadlive.com
27 Jun 2001 10:04:46 +0200

psycopg fully implements dbapi-2.0 (apart from the missing Binary
constructor that will be added before the 1.0 release.)

On 26 Jun 2001 20:50:59 -0700, Nathan Clegg wrote:
> I've tried PyGreSQL, psycopg, and PoPy.  None of them appear to properly
> support paramater binding (specifically do not implement the details from
> footnote 5 in the DB API 2.0 specification).  

psycopg uses the 'pyformat' param style, so it force you to use a
*mapping* to pass in the attributes. if somebody knows of a way to
specify parameters by *position* using pyformat, allowing the use of
sequence i will be glad to implement it. time for a question now...

Q: psycopg correctly put strings obtained by the Date and Time
constructors inside quotes  ('') as requested by the api. it should do
the same (and maybe escape) normal strings? if that's the case don't we
need a String constructor? how is the module supposed to know when a
string is real string and need quoting and when i am passing it just as
convenience but it really is a number? example...

d = {'id':'768', name:'a number'}
curs.execute("CREATE TABLE test (id int4, name text)")
curs.execute("INSERT INTO test VALUES (%(id)s, %(name))")

this will obviously produce the  following (wrong) SQL:

    INSERT INTO test VALUES (768, a number)

what i really wanted was 'a number', quoted. but how can the module
understand that? 

> Are there any packages out
> there for postgresql that fully implement 2.0?  Also, which of these (or
> others) work properly with python 2.1?  I know PyGreSQL has not been updated
> since 1.52.  Seems the change in how long ints are handled can adversely
> affect SQL handling.

moving from 1.5.x to 2.0 only needed a recompile, so i think that moving
from 2.0 to 2.1 will be as easy as "./configure ... && make && make


Federico Di Gregorio
MIXAD LIVE Chief of Research & Technology              fog@mixadlive.com
Debian GNU/Linux Developer & Italian Press Contact        fog@debian.org
                           Don't dream it. Be it. -- Dr. Frank'n'further