Ubuntu Python Connection to SQL Server

Python users on Ubuntu systems may have trouble connecting to Microsoft SQL Server on recent releases including 12.04 LTS. The popular pymssql python library for SQL Server connections contains a nasty bug in the distributed package that runs queries with no errors but returns empty result sets when one or more records are expected. You can view the defect details here: Bug #918896 [pymssql] returns no data from SQL server.

Read the comments for possible workarounds. It appears that the issue has still not been fixed and Debian has not resolved the upstream issue either. Good news is that you can uninstall the dpkg bundled package and then use “pip” to install a working copy of pymssql for your system copy of Python. Here are some hints to get it working, or just review the comments on the above linked bug report.

# Remove the broken pymssql package
apt-get remove python-pymssql 
# Install dependencies
apt-get install python-pip python-dev freetds-dev 
# Install working pymssql with "pip"
pip install pymssql 
Advertisements

About notesbytom

Keeping technology notes on WordPress.com to free up my mind to solve new problems rather than figuring out the same ones repeatedly :-).
This entry was posted in Database, Linux, Python and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s