Skip to main content

Wraps SQL Syntax into a python API.

Project description


Note: this library is pre-alpha.

This version of dbwrapper is highly subject to change. Due to this, I won't be documenting a lot of the API. I tried to make the code fairly readable and code-suggestion friendly. I'm not planning on changing the structure of the major classes, but function arguments will definitely change and features will definitely be removed or addded.

dbwrapper is a lightweight python library designed to simplify interacting with databases of all kinds. This is not an ORM, and I have no plans to make it one. dbwrapper allows programmers to easily create queries using a fluent API. The primary focus of this library is to make data persistance database-agnostic while keeping query overhead low.

Supported Databases

  • SQLite
  • PostgreSQL

Databases with planned support

  • SQL Server
  • MySQL
  • MongoDB


  • Table Creation (via a Builder)
  • Migrations
    • Note: Migrations are not automatically created, you have full control over these!
  • List Tables
  • List Table Columns
  • 'Type Safe' Table and Column retreival
    • Only the presence of tables & columns is validated. Verifying the datatype would incur too much overhead.
  • Aliasing for Tables and Columns
  • SQL Functions (partially implemented)
  • Connection Pooling
  • Built in logging and query profiling (just enable it using logging.basicConfig)

Simple Example Usage

from dbwrapper import sqlite # or postgresql

# If using PostgreSQL, the connection string will need to be changed
connection = sqlite.Connection("data.db")

db = connection.database(sqlite.MASTER_DB)

if "test" not in db.tables:
    with db.table("test").builder() as builder:
        builder.column("id", db.dtypes.integer)
        builder.column("a", db.dtypes.varchar)
        builder.column("b", db.dtypes.float)

        builder.primary_key("id", autoincrement=True)

test = db.tables.test

test.delete().execute() # delete everthing

for i in range(5):
        test.columns.a: "hello world!",
        test.columns.b: i / 5

# no parameters for select() = all columns
results =,
    ) \
    .where(test.columns.b <= 0.5) \


connection.close() # optional, but good practice

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

dbwrapper-python-0.1.1.tar.gz (25.9 kB view hashes)

Uploaded source

Built Distribution

dbwrapper_python-0.1.1-py3-none-any.whl (32.7 kB view hashes)

Uploaded py3

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