Oora
This is intended as a very thin layer above the sqlite3 package by adding a few QOL features:
- default SQLite PRAGMAs fit for server use
- helpers for common write operations (insert, update)
- very basic (forward only) migrations management
- very basic ORM-like functionality for dataclasses (row <-> dataclass)
- lazy connect
Oora is "sql first" and these are out of scope:
- any kind of automatic schema generation
- query abstraction, query generator
install
pip install oora
Usage
import oora
from dataclasses import dataclass
db = oora.DB(
db_path=":memory:", # or /path/to/your/db.sqlite3
# migrations are just pairs of key=>val where key is an arbitrary (but unique) label and val is a SQL script or a callable.
# If val is a callable, it must take a sqlite3.Cursor as first parameter.
# migrations are executed in order
migrations={
# here's an initial migration:
"0000": "CREATE TABLE IF NOT EXISTS user(id INTEGER PRIMARY KEY, name TEXT UNIQUE NOT NULL);",
# simulating a schema evolution, let's add a field:
"0001": "ALTER TABLE user ADD COLUMN email TEXT NULL;",
},
)
db.migrate()
db.insert("user", {"name": "John"})
db.insert("user", {"name": "Jack"})
db.insert("user", {"name": "Jill"})
# dataclasses are perfect to represent rows
# while still allowing custom behaviour
@dataclass
class User:
id: int
name: str
email: str
def __str__(self):
return self.name
# fetch a random instance
user = db.hydrate(User, db.execute("select * from user ORDER BY RANDOM() limit 1").fetchone())
print(f"User(id {user.id}), original name: {user}")
# change name and email
user.name = "Richard"
user.email = "richard@acme.tld"
db.save(user) # name of table is infered from the dataclass name
print(f"User(id {user.id}), updated name: {user} <{user.email}>")
# persist changes
db.commit()
Metadata
Release files for oora 0.2.6
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 |
|---|---|---|---|---|
| oora-0.2.6.tar.gz | 3.7 kB | Without provenance | Details for oora-0.2.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oora-0.2.6-py3-none-any.whl | Python 3 | none | any | Details for oora-0.2.6-py3-none-any.whl |
Total release size: 7.8 kB
Release files / oora-0.2.6.tar.gz
| Download URL | oora-0.2.6.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5f8003af53e5cbef9b500f658485271c3acaafbb0be4b928457f91de462c3f1
|
|
BLAKE2b-256 checksum How to use checksums |
12f5ee87bb474a91275f964e2d0a891765c1d2483db93b3af6b3340ee887ff56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.22
|
Release files / oora-0.2.6-py3-none-any.whl
| Download URL | oora-0.2.6-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dcd08050b7a7ca85403c2291e8713316fa699d2e2297e5a96a2cfb63fd3ed4b6
|
|
BLAKE2b-256 checksum How to use checksums |
ab9d0bbf559d5cd79f7d019e6b8862add751131fd1f1b81661f0a8f33a4ec289
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.22
|
Security for oora 0.2.6
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.