Opyra
The "Buttery Smooth" Registry-Based ORM for Python.
Opyraa next-generation data layer built on top of msgspec. It unifies SQL (Postgres, SQLite) and NoSQL (MongoDB) under a single, ultra-fast, type-safe API using the Registry Pattern.
It eliminates "Global State" and "Boilerplate Fatigue" by using explicit Opyration registries and "Bound Instances" ("The Base").
🚀 Why Opyra
- Registry Pattern: Explicitly register schemas with an
Opyrationengine. No magic globals. - Bound Instances: Objects know where they belong.
user.save()just works because the user carries "The Base" (the engine reference). - Dirty Tracking: Automatic change detection. Calling
.save()only updates what changed (efficientUPDATEvsINSERT). - Universal API: Switch from SQLite to Postgres to Mongo without rewriting your model logic.
- Blazing Fast: Built on
msgspec(faster than Pydantic/JSON) and native async drivers (asyncpg,motor).
📦 Installation
pip install opyra
# Install drivers as needed:
pip install opyra[postgres] # installs asyncpg
pip install opyra[mongo] # installs motor
pip install opyra[sqlite] # installs aiosqlite
⚡ Quickstart
1. Define your Schema
Inherit from Table (SQL) or Document (NoSQL). These are pure data structures (msgspec.Struct).
from opyra import Table, Document
class User(Table):
id: int
name: str
email: str
2. Initialize the Opyration
Create an engine and register your models. This is your "Database Context".
from opyra import Opyration
op = Opyration("postgres://user:pass@localhost:5432/mydb")
op.register(User)
# Now available as 'op.user' (snake_case automation)
3. Use it!
Factory Access (Creating Data):
Use op.user(...) to create a "Bound Instance".
# Create alice attached to this engine
alice = op.user(name="Alice", email="alice@example.com")
# Save detects this is a NEW record (no ID) -> INSERT
await alice.save()
print(alice.id) # ID is auto-populated
Repository Access (Querying Data):
Use op.user.find(...) to search.
# Find by ID
user = await op.user.find(1)
# Find by Template (Fluent API)
users = await op.user(name="Alice").find()
Dirty Tracking (Updating Data): Modify fields naturally. Opyracks changes.
user.name = "Alice Wonder"
# Save detects EXISTING record + Dirty Fields -> UPDATE users SET name='Alice Wonder' WHERE id=1
await user.save()
🏗️ Web Framework Integration
Opyradesigned for dependency injection.
# app.py
op = Opyration(os.getenv("DATABASE_URL"))
op.register(User)
op.register(Post)
# Inject into your app
app.keep('op', op)
# handling request
async def get_user(req, res, ctx):
op = ctx.peek('op')
user = await op.user.find(int(req.params['id']))
res.body = user
License
MIT
Metadata
Release files for opyra 0.0.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 | |
|---|---|---|---|---|
| opyra-0.0.6.tar.gz | 19.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opyra-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.4 kB
Release files / opyra-0.0.6.tar.gz
| Download URL | opyra-0.0.6.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a7dfc1ee9e90fe77298e5c87487a1064a87d8b59049ef212172a04d9e4ee6b6
|
|
BLAKE2b-256 checksum How to use checksums |
2cedbc27883b6f7cb84d1ec97b60618e945ffa5db5adff462e9d128758592d94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.12.3 Linux/6.14.0-37-generic
|
Release files / opyra-0.0.6-py3-none-any.whl
| Download URL | opyra-0.0.6-py3-none-any.whl |
|---|---|
| Size | 22.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
773325409b561c80664d54408ed4bd9103558878550ebc9df24c112834dff0a4
|
|
BLAKE2b-256 checksum How to use checksums |
05d9c8373423fab7c45419d38eb71b4932dc61a28f897f97afa975942726ad03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.12.3 Linux/6.14.0-37-generic
|
Security for opyra 0.0.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.