Connect to Database Using Python
December 8, 2007 2 Comments
Although you can connect to databases using Python on many platforms, the specific examples here are on Ubuntu.
If you would like to connect to MySQL using Python, the process is quite simple. You will need MySQLdb. In Ubuntu, it is quite easy to install
sudo apt-get install python-mysqldb
Once you have installed it, you are ready to go. How do you actually connect to it? I would rather let people smarter than me explain it. One such resource is Using the MySQLdb Interface.
Microsoft SQL Server
However, I can also try to customize install instructions here.
sudo apt-get install python2.5-dev freetds-dev build-essential
You have to download the pymssql module, but choose the platform independent files, not Windows specific. After downloading (I am assuming the .zip file), you may install it using the following steps:
sudo python setup.py install