[DB-SIG] Re: module name
randall at tnr.cc
Thu Sep 2 06:14:48 CEST 2004
Too late. We went with dal with dbapi as a subpackage.
To summarize the previous 50 posts on the subject, we're making an
abstraction layer to hide differences in modules that implement dbapi2.
It is a wrapper. It also adds uniform datetime objects and switchable
paramstyles. The wrapper is the first piece of a larger project, hence
it is a sub-package. Although, you will only have to import dal to use
it. dal will contain a function that returns a wrapped driver.
Here is an example:
dbmod = dal.wrapdriver('psycopg')
cn = dbmod.connect(database='mydb')
cs = cn.cursor()
params = dbmod.Date(2004, 1, 1)
query = "select * from foo where goo > ?"
result = cs.fetchall()
A few things to note. Even though psycopg uses mx.DateTime, the Python
datetime.date type was used. dbmod.Date(2004, 1, 1) generated a Python
datetime.date object that was translated into an
mx.Datetime.DateTimeType during cs.execute(). Also note that I used the
'qmark' paramstyle even though psycopg uses 'pyformat'. Those are the
defaults, although both are configurable.
Mike Dewhirst wrote:
> Could you maybe post the module description in 50 words or less?
> DB-SIG maillist - DB-SIG at python.org
More information about the DB-SIG