Introduction
The db module is a DB API wrapper. It provides a DB API-compliant API that
wraps real underlying DB API drivers, simplifying some non-portable operations
like connect() and providing some new operations.
Some drivers come bundled with this package. Others can be added on the fly.
Getting the List of Drivers
To get a list of all drivers currently registered with this module, use the
get_driver_names() method:
import db
for driver_name in db.get_driver_names():
print driver_name
Currently, this module provides the following bundled drivers:
| Driver Name,
as passed to
get_driver() |
Database |
Underlying Python
DB API module |
| dummy |
None |
db.DummyDB |
| gadfly |
Gadfly |
gadfly |
| mysql |
MySQL |
MySQLdb |
| oracle |
Oracle |
cx_Oracle |
| postgresql |
PostgreSQL |
psycopg2 |
| sqlserver |
SQL Server |
pymssql |
| sqlite |
SQLite 3 |
sqlite3 |
To use a given driver, you must have the corresponding Python DB API module
installed on your system.
DB API Factory Functions
The Binary(), Date(), DateFromTicks(), Time(),
TimeFromTicks(), TimeStamp() and TimestampFromTicks() DB API
functions can be found in the DB class. Thus, to make a string into a BLOB
with this API, you use:
driver = db.get_driver(driver_name)
db = driver.connect(...)
blob = db.Binary(some_string)