Skip to main content

DB wrapper library

Project description

Simple library that makes working with databases more convenient in python.

notanorm can return objects instead of rows, protects you from injection, and has a very simply driver interface.

Decidedly not an ORM, since ORM's are typically mega libraries with often confusing semantics.

Example:

from notanorm import SqliteDb 
from notanorm import MysqlDb 

fname = ":memory:"

# default options are 
db = SqliteDb(fname)

# no special create support, just use a string
db.query("create table foo (bar text, iv integer primary key)")

# insert, select, update, and upsert are convenient and do the right thing
# preventing injection, normalizing across db types, etc.

db.insert(bar="hi", iv=1)
db.insert(bar="hi", iv=2)
db.insert(bar="ho", iv=3)

db.upsert(bar="ho", iv=4)                   # primary keys are required for upserts

db.select("foo", bar="hi")[0].bar           # hi
db.select("foo", {"bar": "hi"})[0].iv       # 1

db.count("foo", bar="hi")                   # 2

class Foo:
    def __init__(self, bar=None, iv=None):
        self.bar = bar
        self.iv = iv

# create a class during select
db.register_class("foo", Foo)
obj = db.select_one("foo", bar="hi")
print(obj.bar)                              # hi

Project details


Download files

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

Files for notanorm, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size notanorm-0.0.4-py3-none-any.whl (8.9 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page