A tiny SQLite ORM for Python.
Project description
dorm
A small SQLite ORM for Python 3. You probably shouldn't use this, but if you want to anyway, pip install dorm
and look at the tests for how to do so.
Migrations
Dorm has the most basic migration support imaginable:
# Generates a schema migration if it detects any changes.
python -m dorm --db=books.db --models=project.models --migrations=project.migrations generate
# Migrates to the latest migration (sorted by filename in the --migrations module).
python -m dorm --db=books.db --models=project.models --migrations=project.migrations migrate
Existing migrations are run automatically when calling dorm.setup
with the migrations
argument set. This
is to ensure a good first-run experience and automatic upgrades for end users. If migrations
is not set,
any detected schema changes will be applied automatically to the database.
Asynchronous Tables
Dorm can be used with asyncio
by simply subclassing AsyncTable
instead of Table
. The insert
class method,
and save
and refresh
instance methods become coroutines in that case. Also, the query
class method will return
an AsyncQuery
instance, with coroutines for count
, values
, get
, update
, and iteration via __aiter__
(i.e. async for obj in MyTable.query()
).
Migrations and introspection still happen synchronously, since they tend not to happen during times where they would benefit from being asyncronous.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file dorm-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: dorm-0.4.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edbb10c6ce79cbff85a87b5829dc4e985c05db0a27391913ea9e50c7af111c53 |
|
MD5 | 8b69f6a4241689b4ac9e805113e06885 |
|
BLAKE2b-256 | 01ee9bd19729eb46f8ce1230c6787ac7ce782faaea8919e184e72a232dca934a |