[DB-SIG] Postgres DB API-compliant Python access

M.-A. Lemburg mal@lemburg.com
Fri, 17 Mar 2000 15:36:31 +0100


Hrvoje Niksic wrote:
> 
> This list is probably not the right place for this question, but
> anyway...
> 
> I need to access the PostgreSQL database from Python.  However, it
> seems that the default Python wrapper is not DB-compliant.  If at all
> possible, I'd really like to avoid learning yet another SQL wrapper
> API.  (And besides, I have some DB-based MySQL code that I'd like to
> convert.)
> 
> I noticed that Postgres supports ODBC.  Is that known to work with
> mxODBC?  Does one need a driver manager as well?  Are there efficiency
> issues?

Yes...

create a new subpackage PostgreSQL as documented; then add this to
Setup:

#### ODBC interface for PostgreSQL 6.5.x ODBC driver
#
# Note: you will have to fix the paths to point to your installation
# directories.
#
        -DPostgreSQL \
        -DDONT_HAVE_SQLDescribeParam \
        -I/usr/local/pgsql/include/iodbc \
        /usr/local/pgsql/lib/libpsqlodbc.so
#
#

and a new #ifdef level to mxODBC.h:

#ifdef PostgreSQL
/* PostgreSQL ODBC driver */
# include "iodbc.h"
# include "isql.h"
# include "isqlext.h"
# define MXODBC_INTERFACENAME "PostgreSQL ODBC"
#else

...

#endif

The __init__.py file of the subpackage probably also needs
some tweaking.

Don't know how efficient the PostgreSQL ODBC interface is,
but at least you get DB API compliant access this way.

> Is the default Python wrapper scheduled to be made DB-compliant soon?
> In that case, I could wait for that, and/or participate in testing.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/