Add pypyodbc support

Issue #2795 wontfix
created an issue

pypyodbc is a drop-in replacement for pyodbc that works on top of pypy:

It would be nice if there was support for it out of the box in SQLAlchemy so that we could switch between cpython and pypy with a swap of a connection string. Here are their docs on all that is required:

Comments (11)

  1. Michael Bayer repo owner

    have you tried pypyodbc? seems to be hanging for me. You can pass it to create_engine() like this:

    from sqlalchemy import create_engine
    import pypyodbc
    e = create_engine("mssql+pyodbc://scott:tiger@ms_2005", echo=True, module=pypyodbc)
    c = e.connect()
    print c.execute("select 1")
  2. Michael Bayer repo owner

    OK I've gotten some pypyodbc tests to run, will need its own connector/dialect with some different options and different way of detecting server version info. pypyodbc isn't working for me with pypy at the moment but is working with cpython.

    here's the flags i need to have detected differently when its in use:

    diff --git a/lib/sqlalchemy/connectors/ b/lib/sqlalchemy/connectors/
    index 284de28..b920516 100644
    --- a/lib/sqlalchemy/connectors/
    +++ b/lib/sqlalchemy/connectors/
    @@ -47,7 +47,7 @@ class PyODBCConnector(Connector):
         def dbapi(cls):
    -        return __import__('pyodbc')
    +        return __import__('pypyodbc')
         def create_connect_args(self, url):
             opts = url.translate_connect_args(username='user')
    @@ -138,6 +138,7 @@ class PyODBCConnector(Connector):
                 self.supports_unicode_binds = True
    +        self.supports_unicode_binds = False
             # run other initialization which asks for user name, etc.
             super(PyODBCConnector, self).initialize(connection)
    diff --git a/lib/sqlalchemy/dialects/mssql/ b/lib/sqlalchemy/dialects/mssql/
    index 90fd1f3..d5fa15d 100644
    --- a/lib/sqlalchemy/dialects/mssql/
    +++ b/lib/sqlalchemy/dialects/mssql/
    @@ -1127,6 +1127,7 @@ class MSDialect(default.DefaultDialect):
         def initialize(self, connection):
             super(MSDialect, self).initialize(connection)
    +        self.server_version_info = MS_2008_VERSION
             if self.server_version_info[0](0) not in list(range(8, 17)):
                 # FreeTDS with version 4.2 seems to report here
                 # a number like "95.10.255".  Don't know what
  3. Log in to comment