#259 query method on connection

closed-fixed
Oleg Broytman
Postgres (36)
5
2010-01-06
2009-12-31
dkeeney
No

In the end of makeConnection, in postgres/pg_connection.py, the method 'query' is called on the connection object.

The connection object has just been created using a call to one or another DB API constructors, and the DB API spec does not have a 'query' method. As far as I know, the psycopg2 implementation does not have such a method either.

I patched my copy by adding an hasattr call to verify the existence of 'query' method, but I suspect a better fix is to use method is .execute, so the end of makeConnection would be:

dbEncoding = self.dbEncoding
if dbEncoding: # and hasattr(conn,'query'):
conn.execute("SET client_encoding TO %s",dbEncoding)
return conn

Discussion

  • Oleg Broytman
    Oleg Broytman
    2010-01-06

    Fixed in the revisions 4067, 4068 (branch 0.12 and the trunk.) Thank you!

     
  • Oleg Broytman
    Oleg Broytman
    2010-01-06

    • assigned_to: nobody --> phd
    • status: open --> closed-fixed