Hello all,

 

I have been attempting to integrate PyGreSQL's DBAPI compliant module as
the database driver for SQLAlchemy.  After initial searching, I found
that you can pass the driver as the "module" argument when initializing
SQLAlchemy, and that this was the way to get it to start working with
PyGreSQL.  

 

The only Python PostgreSQL driver that SQLAlchemy "supports" is
Psycopg2, but I am unable to use that library due to its license
restrictions, and I have been using PyGreSQL for quite some time now, so
it's a much more attractive alternative.

 

I had been attempting to write the code using Psycopg2 as the Postgres
driver for SQLAlchemy and was able to reflect my schema without
hang-ups, but wanted to try using PyGreSQL.  My first attempt at
replacing the driver and reflecting my schema resulted in the following
error:

 

"sqlalchemy.exc.OperationalError: (OperationalError) internal error in
'BEGIN': not all arguments converted during string formatting 'select
current_schema()' [None]".

 

Obviously, this is not in the PyGreSQL code, so I chased this error down
the stack trace to the method Connection_cursor_execute() method in
base.py (SQLAlchemy).  I changed the exception that is caught there to
look into exactly what is happening, and then ran my code again,
resulting in an error being thrown in PyGreSQL:

 

"pg.OperationalError: internal error in 'BEGIN': not all arguments
converted during string formatting"

 

I chased this error to where it was being raised, which was in lines
290-291 in pgdbCursor.executemany() method in pgdb.py.  I removed the
exception handling so I could further find where things were going
wrong.  I found that the error in question was:

 

"TypeError: not all arguments converted during string formatting"

 

This was occurring at line 222 in pgdb.py in the method
pgdbCursor._quoteparams().  After some more inspection, I found that the
params argument was a list containing only the value None, that is,
[None].  I added a check at the beginning of that method for this value:

 

if params == [None]:

                return string

 

After this change, my code functioned exactly the same as when I was
working with Psycopg2, and I've been running fine for about a month of
work. 

 

My question is whether or not this is something that is OK to change, as
I am not familiar with the inner workings of PyGreSQL and wanted to see
if there are any repercussions of this change that I could potentially
be missing.

 

I am using Python 2.5.4, working on Windows XP SP 2,  Using SQLAlchemy
0.5.6 and the latest stable version of PyGreSQL.

 

Thanks in advance,

Mike

_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql

Reply via email to