Skip to main content

DB-API made easier

Project description

:Author:

Keith Gaughan (http://stereochro.me)

Repo:

https://github.com/kgaughan/dbkit

Documentation:

http://dbkit.readthedocs.org/

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)

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.1.3.tar.gz (22.1 kB view details)

Uploaded Source

File details

Details for the file dbkit-0.1.3.tar.gz.

File metadata

  • Download URL: dbkit-0.1.3.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dbkit-0.1.3.tar.gz
Algorithm Hash digest
SHA256 af12944f397d0ec4f0a19dab67276535ef4321b648c2dc898ab83f8875b3df52
MD5 d6a7b585fbf7821b592d079d8dda2a82
BLAKE2b-256 2ba002784e9485bd9ab43d62f1fbfcb2984685a125ff3bb4ed9e823867a2e055

See more details on using hashes here.

Supported by

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