Usage
Install:
pip install ormlite
Sample code:
from datetime import datetime
from ormlite import connect_to_sqlite, migrate, model, field, select, upsert
@model('persons')
class Person:
email: str = field(pk=True)
age: int
height: str
last_seen: datetime = datetime.now()
db = connect_to_sqlite("demo.db")
migrate(db)
upsert(db, [Person('me@me.com', 23, "5ft 10in")], update=[])
models = select(Person).where("age = '23'").models(db)
print(list(models))
# Output: [Person(email='me@me.com', age=23, height='5ft 10in', last_seen=datetime.datetime(...))]
db.close()
Motivation
I wanted to query a sqlite database, without writing verbose queries. Previously, for work, I've used django's orm for interacting with sql databases. But for a recent small personal project, I wanted a library to interact with sqlite without depending on an entire web framework.
After I deciding to build my own library, I decided to embrace modern python idioms. So my library is built on top of the dataclasses library in the standard lib.
To keep scope small, ormlite only interops with sqlite, not other sql databases. I have no future plans to change this.
Use case
ormlite operates off the principle, that your python source code is the source of truth for the state of the sql tables. Migrations are run in a single step, it checks for differences between your python tables and your sql database. Then it applies sql migrations immediately.
Django & Ruby on Rails, have a separate step whereby migrations are serialized to files. Migrations are thus shared across dev machines, and to production this way.
Since ormlite doesn't do this, it's not suitable for production deployment or teams of devs.
My use case for the library involves running scripts on my local machine, so I enjoy not dealing with the hassle of an evergrowing list of migrations in my repo.
Metadata
Release files for ormlite 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ormlite-0.2.1.tar.gz | 13.8 kB | Without provenance | Details for ormlite-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ormlite-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for ormlite-0.2.1-py3-none-any.whl |
Total release size: 25.8 kB
Release files / ormlite-0.2.1.tar.gz
| Download URL | ormlite-0.2.1.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c7781a416dd70963ad65c450866c2d06a8e18338d9eea0f2a706a139e54a8b3
|
|
BLAKE2b-256 checksum How to use checksums |
cbb83a7f638c23338fa80045956c61d968012ec41eeb4cc707e9f1ecedbad9de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.1 CPython/3.11.4
|
Release files / ormlite-0.2.1-py3-none-any.whl
| Download URL | ormlite-0.2.1-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c670700cbb65b54ee657e8c655307b9f4093e23ab5c1342a5b4d6886bdb4fee9
|
|
BLAKE2b-256 checksum How to use checksums |
064f4990d6d6eee5176c4de9f2c01bf75942013b91569f5ada6fe541e264edf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.1 CPython/3.11.4
|
Security for ormlite 0.2.1
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.