We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.

Are there any interfaces to database packages in Python?

Python has a standard DB-API interface (see PEP 249), and compatible implementations are available for all widely used database engines. See the Database Topic Guide for details.

Python 2.5 and later includes a DB-API compliant database package, sqlite3, which uses an embedded SQL database, SQLite.

>>> import sqlite3 as dbapi
>>> db = dbapi.connect("database.db")
>>> c = db.cursor()
>>> for record in c.execute("select * from table"):
...     print record

For earlier versions, this database can be downloaded separately (see http://pysqlite.org).

There’s also a standard bsddb package which provides an interface to the BerkeleyDB library. Interfaces to disk-based hashes such as dbm and gdbm are also included with standard Python.

For bridging Python and databases more naturally, there are a variety of object-relational mapping tools, like SQLObject and SQLAlchemy.

IronPython can use all DotNet database connections, of course, and Jython can use all Java database connections.

CATEGORY: library

CATEGORY: database