What is it?

dbx is a simple SQL database abstraction layer for Python.

The goal of dbx is to make using a SQL database as simple as possible while providing a consistent API across different databases.

The Python DB-API is powerful, yet complex. An application that simply needs to execute a query and iterate over the results does not need all that power and can greatly benefit from a simpler interface.

This software is public domain.

How to install pydbx

Download the pydbx package. The latest published pydbx package is pydbx-0.14.tar.gz.

Unpack the pydbx package:

gunzip pydbx-0.14.tar
tar -xf pydbx-0.14.tar
cd pydbx-0.14

As root, install the dbx package:

python install

Database support

dbx supports the following databases:


This is an example using DB-API:

    import MySQLdb
    conn = MySQLdb.connect(db="test", host="localhost",
                           user="user", passwd="pass")
    cursor = conn.cursor(MySQLdb.cursors.DictCursor)
    cursor.execute("SELECT name, phone FROM User")
    rows = cursor.fetchall()
    for i in rows:
        print i["name"], i["phone"]

This is an example using dbx:

    import dbx.mysql as dbx
    db = dbx.MySQL("test", "localhost", "user", "pass")
    rows = db.listQuery("SELECT name, phone FROM User")
    for i in rows:
        print i["name"], i["phone"]

As you can see, it is easier to use dbx because you do not need to deal with cursors. You also do not need to worry about how results are returned, since they are always returned as dictionaries. Exceptions are also handled consistently.

David Phillips Valid HTML 4.01!