[DB-SIG] db module wrapper

Vernon Cole wnvcole at peppermillcas.com
Thu Aug 19 22:59:15 CEST 2004

Ah, the games begin!

Here is my suggestion for how to encode parameters into an cursor.execute
call: DON'T!

Use an arbitrary argument list, formatted like a PRINT statement:

 cursor.execute("Select foo from table where goo >",foo,"and bar =",bar)

Now THAT is easy to read and reliable.  

"BUT," you say: "the other way is easy to parse and convert into other

I quote from Guido on this list last January 2nd:
vvvvv (begin clip) vvvvvv

For Python itself, making the life of the developers harder is
usually considered okay if it makes the life of the users easier.

I'm curious if the life of the users isn't made *considerably* harder
by some gratuitous differences between DB-API implementations, when
a user needs to switch database vendors or (a slightly different
case!) needs to support multiple vendors simultaneously.

Yes, you can write all your code using the facilities to inquire
DB-API features, but in practice nobody does that until they are
forced to consider multiple versions and realize just how different
they are.  In a few months on this list I've seen many folks post
about this.

(Of course, you can argue that the database vendors are a major source
of the differences -- the differences in SQL syntax are indeed
staggering!  But I'm not sure if that gives DB-API developers an
excuse -- otherwise we might as well have no standard at all.)
^^^^^ (end clip) ^^^^^^

Let's go for the gold. We do not need to copy ANY given dialect of SQL. We
need to find OR CREATE a dialect which will give our application programmers
the best possible productivity.

-----Original Message-----
From: M.-A. Lemburg [mailto:mal at egenix.com]
Sent: Thursday, August 19, 2004 2:13 PM
To: Dieter Maurer
Cc: db-sig at python.org
Subject: Re: [DB-SIG] db module wrapper

Dieter Maurer wrote:
> Randall Smith wrote at 2004-8-18 15:22 -0500:
>>* Standardize the params input to use the ? operator and a list.  The 
>>module translates input params and query into the one appropriate for 
>>the  native module.  For example with cx_Oracle: "Select foo from table 
>>where goo > ?" with params [myparam] converts to "Select foo from table 
>>where goo > :var1" with params {'var1':myparam}.  This is working with 
>>both psycopg and cx_Oracle.
> Why are you replacing a readable and reliable syntax by one
> that is difficult to read and unreliable?
>   As soon as you have a couple of "?", it becomes quite difficult
>   to grasp...

You get used to it rather quickly ;-) (and it's easy to parse and
convert into the other formats).

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Aug 19 2004)
 >>> 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,FreeBSD for free ! ::::
DB-SIG maillist  -  DB-SIG at python.org

More information about the DB-SIG mailing list