Thursday, February 5, 2009

pymssql and sqlalchemy

At the time of this writing the latest version of sqlalchemy (0.5.2) does not support the recent re-write of pymssql (1.0.0), which was released last week.


attempting to create a sqlalchemy engine object will result in an exception:

File "/lib/python2.5/site-packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/databases/mssql.py", line 1294, in create_connect_args
self.dbapi._mssql.set_query_timeout(self.query_timeout)
AttributeError: 'module' object has no attribute 'set_query_timeout'
>>>

According to the pymssql news page, the low level module in this major version release is not backwards compatible:

  • BEWARE however, if you were using the lower level _mssql module, it changed in incompatible way. You will need to change your scripts, or continue to use pymssql 0.8.0. This is why major version number was incremented.
As a 'work-around' you can always install an older stable version of pymssql (0.8.0)

$easy_install pymssql==0.8.0

2 comments:

Anonymous said...

I'm curious, why are you using pymssql instead of pyodbc? pymssql has significant problems plus it's no longer supported by Microsoft and will not be distributed in future versions of SQL Server.

clayg said...

I've never tried pyodbc, I'll look into it. I've developed many applications with pymssql and never had any problems.

In what universe does microsoft acknowledge any open-source database connection module like pyodbc OR pymssql? Much less support or distribute!? No, I'm sure we're all quite on our own, thank goodness for the internet...