Skip to content
AnthonyDB edited this page Feb 28, 2012 · 3 revisions

Python interacts with database backends using various database interfaces, or APIs. There are different database APIs for each type of database, whether you're dealing with MySQL, Postgres, Oracle, SQLite, etc. Most of these APIs conform to a common standard known as the Python DB-API 2.0. This standardization means that you can use the same Python syntax to query databases, regardless of which API and database back end you're using. There are some minor exceptions, but on the whole the syntax is pretty uniform across the board.

If the developers of the official database API don't offer a version that works with your operating system and/or version of Python, you can try searching for unofficial binaries at sites like the below. Be warned that these are not officially supported, documented, etc.

MySQL

python-mysqldb is Python's primary database adapter for MySQL. Unfortunately, as of February 2011, it only supported Python versions 2.3-2.6. There are various unofficial binaries floating around for newer Python versions, so those might be worth a try.

Installing python-mysqldb can be tricky, especially on Windows. Below are some links that might be useful.

Microsoft SQL Server

pyodbc is a library that creates connections not just to SQL Server but several other databases as well.

Clone this wiki locally