Compatibility problems with PyGreSQL

Issue #1691 resolved
Former user created an issue

In the SQLAlchemy 0.5 branch, the method get_default_schema_name() in databases.postgres has the following code:

return connection.scalar("select current_schema()", None)

This results in the DBAPI execute method being called with parameters set to [None](None) which is not expected here since the operation takes no parameters. It seems psycopg2 silently ignores this, but other drivers such as PyGreSQL raise an exception. It would be nice if this could be fixed (by removing the None parameter, see patch), because it seems to be the only problem that prevents SQLAlchemy from working with PyGreSQL properly.

In the SQLAlchemy 0.6 branch this is implemented correctly already, but this branch does not work with PyGreSQL any more (I tried setting module=pgdb, creator=pgdb.connect, and using postgresql+pygresl://... in the url).

-- Christoph Zwerschke

Comments (8)

  1. Mike Bayer repo owner

    To support pygresql in 0.6 only requires dropping a compatibility file into sqlalchemy/dialects/postgresql/ . It would be very helpful if you could construct/ test out a pygresql.py file for us.

    I guess you are passing a DBAPI module along to create_engine() to achieve this result. The change is in e249dfd0ff2067e63b5654ca8bbd4177d97c7561 but we do not support new features or alternative DBAPIs in 0.5, so 0.6 would be your best bet here for future issues.

  2. Mike Bayer repo owner

    also in 0.6 just leave the "+pygresql" off the URL. The "module" argument still works but there's no awareness that its not dealing with "psycopg2".

  3. Former user Account Deleted

    Thanks. Ok, I'll try to create a compatibility file for pygres.

    In 0.6, when I set the "module" argument to pgdb, alchemy still tried to import psycopg2.extensions in the visit_pool() method which I think makes no sense here.

  4. Former user Account Deleted

    Btw, are there any automated tests for checking whether a different db api 2 driver works with sqlalchemy?

  5. Log in to comment