Skip to main content
https://secure.travis-ci.org/kgaughan/dbkit.png?branch=master https://pypip.in/v/dbkit/badge.png

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

Here’s an example:

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.

Installation

dbkit can be installed with either either pip (recommended):

$ pip install dbkit

Or with easy_install:

$ easy_install dbkit

Development

The repos can be found on Github while the documentation can be found on Read the Docs.

Change history

0.2.4 (2015-11-30)

  • Python 3 support.

0.2.3 (2015-11-26)

  • Context.cursor() now always creates a transaction. The lack of this outer transaction meant that PostgreSQL would end up with a large number of idle transactions that had neither been committed or rolled back.

0.2.2 (2013-04-04)

  • Scrap unindent_statement().

  • Derive all dbkit exceptions from Exception.

  • Clean up connection pinging code.

  • Add make_placeholders() for generating statement placeholders safely.

  • Add to_dict() for converting resultsets to dicts mapped off of a particular field.

0.2.0 (2012-10-16)

  • Add last_row_id().

  • Pools now can have custom mediators.

  • Cursors are now tracked.

  • Pooled connections are no longer closed prematurely.

  • Row factories are now usable outside of context safely.

0.1.4 (2012-10-11)

  • execute*() now returns the number of affected rows.

  • Add last_row_count and last_row_id to Context.

  • Remove DummyPool and ThreadAffinePool, though the latter may be returning.

  • Stablise the behaviour of Pool when dealing with expired connections.

  • Documentation version is now pegged directly to the library.

0.1.2 (2012-09-02)

  • Initial revision with a changelog.

Metadata

Release files for dbkit 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dbkit 0.2.4
File Size Uploaded Provenance Actions
dbkit-0.2.4.tar.gz 28.0 kB Without provenance Details for dbkit-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dbkit 0.2.4
File Interpreter ABI Platform Actions
dbkit-0.2.4-py2.py3-none-any.whl Python 3, Python 2 none any Details for dbkit-0.2.4-py2.py3-none-any.whl

Total release size: 40.1 kB

Release files / dbkit-0.2.4.tar.gz

Download URL dbkit-0.2.4.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
40310bf877ff54dae9a6c650616bca7ff7505a6ff10334de4f89182c4c3b38c9
BLAKE2b-256 checksum
How to use checksums
4370e62edce902e8d12c937a28e8e071ef2a05fa78eba62fa1cd77332faef1f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / dbkit-0.2.4-py2.py3-none-any.whl

Download URL dbkit-0.2.4-py2.py3-none-any.whl
Size 12.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b6ffde35c55b5956996c0fe6847cb01c8aadc8fb7a9a90fdfe1c2f40b8821dda
BLAKE2b-256 checksum
How to use checksums
a43e604b43c94ef2c99acd4067a91bdf19f8003ca4adadbade75da8829600325
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for dbkit 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page