Skip to main content

DB-API made easier

Project description

dbkit is a library that abstracts away at least part of the pain involved in dealing with DB-API 2 compatible database drivers.

https://secure.travis-ci.org/kgaughan/dbkit.png?branch=master
from dbkit import connect, query
from contextlib import closing
import sqlite3

with connect(sqlite3, 'counters.db') as ctx, closing(ctx):
    for counter, value in query('SELECT counter, value FROM counters'):
        print "%s: %d" % (counter, value)
Author:

Keith Gaughan (http://stereochro.me)

Repo:

https://github.com/kgaughan/dbkit

Documentation:

http://dbkit.readthedocs.org/

Overview

dbkit is intended to be used in circumstances where it is impractical or overkill to use an ORM such as SQLObject or SQLAlchemy, but it would be useful to at least abstract away some of the pain involved in dealing with the database.

Features:

  • Rather than passing around database connections, statements are executed within a database context, thus helping to decouple modules that interface with the database from the database itself and its connection details.

  • Database contexts contain references to the exceptions exposed by the database driver, thus decoupling exception handling from the database driver.

  • Easier to use transaction handling.

  • Easier iteration over resultsets.

  • Connection pooling. In addition, any code using pooled connections has no need to know connection pooling is in place.

  • Query logging.

Non-aims:

  • Abstraction of SQL statements. The idea is to get rid of the more annoying but necessary boilerplate code involved in dealing with DB-API 2 drivers, not to totally abstract away SQL itself.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbkit-0.2.2.tar.gz (25.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page