How to work with MSSQL in Python on Linux

Actually, I like to work with SQLite or MySQL because they are so very easy to find and work with. However, sometimes we might need to work with Microsoft SQL. Working with MSSQL on MS Windows is quite easy. There are so many drivers on that platform. Unfortunately, I am living on Linux, Ubuntu Feisty Fawn, and my favorite programming language is [Python][]. As a result, I have to find a way to contact MSSQL through Python.

The hero I found is FreeTDS which aims to provide a set of APIs for accessing Microsoft SQL or Sybase. So the only missing piece is driver for Python. There are several options for choosing the most useful Python module. Finally, I found pymssql seems to be the most complete as of now. By the way, Ubuntu Feisty don't have pymssql so I have to install it manually.

  1. Install freetds-dev

    apt-get install freetds-dev
    
  2. Download and extract pymssql.

    tar xzvf pymssql-0.8.0.tar.gz
    
  3. Build and install

    python setup.py install
    

That's all. You should be able to develop some codes right now.

Tags: , , , ,

Post new comment