[DB-SIG] db module wrapper

Randall Smith randall at tnr.cc
Thu Aug 19 18:31:36 CEST 2004


One thing I'm surprised nobody mentioned is a uniform login method. 
Does anyone have a suggestion for this?  I thought about using the jdbc 
standard.

Randall

Randall Smith wrote:
> I have created a db module wrapper for hiding the differences between 
> the DB API 2 implementations.  I currently testing it on psycopg and 
> cx_Oracle.  Some of the things I have done are:
> 
> * Standardize time objects to use Python datetime.datetime and 
> datetime.date classes for both input and output.  The module converts 
> between types transparently.  This is working on both psycopg and 
> cx_Oracle.
> 
> * 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.
> 
> * In addition, I also used Kevin Jacob's db_row module to give access by 
> name to the rows returned from a query.
> 
> Features can be turned off.
> 
> First of all, am I reinventing the wheel here?  Does a wrapper already 
> exist that hides API implementation differences?  Second, do you have 
> any suggestions for standardizing?  I used the ? operator for params. Is 
> there a better option?  How do you feel about using the datetime 
> module?  I know it is not available in earlier versions of Python, but I 
> want to stay in the Python standard library if possible.  I would love 
> feedback.
> 
> Randall
> _______________________________________________
> DB-SIG maillist  -  DB-SIG at python.org
> http://mail.python.org/mailman/listinfo/db-sig


More information about the DB-SIG mailing list