Ben Hamner Ben Hamner - 4 years ago 222
Python Question

SQL Server, Python, and OS X

What's a good way to interface Python running on OS X with a cloud-based SQL Server database?


With pyodbc I'm getting this error:

>>> import pyodbc
>>> cnxn = pyodbc.connect('DRIVER={SQL Server};;DATABASE=asdf;UID=asdf;PWD=asdf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyodbc.Error: ('00000', '[00000] [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (0) (SQLDriverConnect)')

Answer Source

SQLAlchemy is probably your best bet. It has an ORM, but doesn't require its use. MS SQL is supported through a number of DBAPI projects.

As for lower-level interfaces, here's the three DBAPI projects listed at SQLAlchemy's site that have vanilla Python and Unix support:

  • pymssql appears to be the simplest to set up; it doesn't require FreeTDS.
  • pyodbc appears to be under more active development than pymssql.
  • mxODBC is a commercially-licensed interface to many databases.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download