Python Database Interfaces - Any Standard?

Martin von Loewis loewis at informatik.hu-berlin.de
Wed Dec 27 19:50:48 EST 2000


"Thomas A. Bryan" <tbryan at python.net> writes:

> I haven't done much with Python and databases (yet), but I think that the 
> idea is to be able to write 
> 
> import DCOracle
> dbh = DCOracle.Connect( connect_string )
> query = dbh.cursor()
> query.execute( query_string )
> 
> 
> To change to PostgreSQL, you'd have to change the import and the connection.

If you anticipate change to another database, you write

import DCOracle as DB
dbh = DB.Connect( connect_string )
query = dbh.cursor()
query.execute( query_string )

For PostgreSQL, you only need to write

import pg as DB

Now, it is common that Python provides a wrapper module, like the os
module or the anydbm module. However, there was no demand for such a
wrapper in Python, yet.

Regards,
Martin



More information about the Python-list mailing list