A base framework for a plug-and-play ORM
Project description
PlugORM
PlugORM is a driver-first ORM framework built around the concept of a Surface Driver.
It unifies parsing, execution, and simplification into a single pipeline and gives you the tools to define your own ORM “surface.”
✨ Core Concepts
-
Surface Driver
The main entrypoint. A surface driver wires together:- an ILDriver (internal language → dialect parser)
- a ConnectionDriver (executes against a database or backend)
- an optional Simplifier (post-processes raw results)
-
Intermediate Language (IL)
Queries and schemas are translated into an IL, which is then consumed by the connection driver. -
Toolchain
Each driver becomes a step in a sync or async toolchain. Toolchains are validated and executed automatically. -
Errors with Context
Dedicated exceptions for link validation, parsing failures, execution errors, async/sync mismatches, and more.
🚀 Installation
pip install plugorm
🔧 Quick Example
Here’s how to define and run a surface driver:
import logging
from plugorm import ILDriver, ConnectionDriver, Simplifier, SurfaceDriver
class MyIL(ILDriver):
input_ = {"il"}
output = {"sql"}
def parse(self, il): ...
class MyConn(ConnectionDriver):
input_ = {"sql"}
output = {"raw"}
def connect(self): ...
def close(self): ...
def execute(self, statement): ...
class MySimplifier(Simplifier):
input_ = {"raw"}
output = {"final"}
def parse(self, rows): ...
class MySurfaceDriver(SurfaceDriver):
input_ = {"pythonic"}
output = {"il"}
@SurfaceDriver.dialect
def getall(self): ...
# Build surface
driver = MySurfaceDriver(
conn_driver=MyConn(),
il_driver=MyIL(),
simplifier=MySimplifier(),
logger=logging.getLogger("plugorm")
)
with driver as db:
result = db.getall()
print(result)
🧩 Architecture
Surface Driver -?> IL Driver -> Connection Driver -?> Simplifier
Each driver must declare compatible input_ and output sets. The surface driver validates these links before building toolchains.
⚡ Sync & Async Support All drivers can be sync, async, or both.
If a driver only supports async, but you try to use it in a sync toolchain, NotSyncError is raised.
If a driver only supports sync, but you build an async toolchain, you can enable fallback=True to run it in a background thread.
async with driver as db:
result = await db.getall()
📃 Documentation
For more information, read the documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plugorm-0.2.0.tar.gz.
File metadata
- Download URL: plugorm-0.2.0.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a375348e2fe6db21668270c57cf6105bba695aee4c86d1b919ad0c187807b55b
|
|
| MD5 |
4ca40875e7ca8357ca57b2200e3cde07
|
|
| BLAKE2b-256 |
6849c860de8ec75d7d947c86cbce9956bebdf3ad72ad80658a64973561ba487e
|
Provenance
The following attestation bundles were made for plugorm-0.2.0.tar.gz:
Publisher:
python-publish.yml on anaphan1/plugorm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plugorm-0.2.0.tar.gz -
Subject digest:
a375348e2fe6db21668270c57cf6105bba695aee4c86d1b919ad0c187807b55b - Sigstore transparency entry: 455479614
- Sigstore integration time:
-
Permalink:
anaphan1/plugorm@e34a63831bd28a03b05cc0a6010cfe2e6c90f78d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/anaphan1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e34a63831bd28a03b05cc0a6010cfe2e6c90f78d -
Trigger Event:
release
-
Statement type:
File details
Details for the file plugorm-0.2.0-py3-none-any.whl.
File metadata
- Download URL: plugorm-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
841640755206ca1db7cf9d4856f434d8d923e4c53279acd81205eaea6d8335ab
|
|
| MD5 |
b5ae9430f43e0f7d57ae7ebee35fe59d
|
|
| BLAKE2b-256 |
9de0963ecdcd7fdc435cb09234fdaf896bc04345a2aa1c0b1f420b160a291842
|
Provenance
The following attestation bundles were made for plugorm-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on anaphan1/plugorm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plugorm-0.2.0-py3-none-any.whl -
Subject digest:
841640755206ca1db7cf9d4856f434d8d923e4c53279acd81205eaea6d8335ab - Sigstore transparency entry: 455479622
- Sigstore integration time:
-
Permalink:
anaphan1/plugorm@e34a63831bd28a03b05cc0a6010cfe2e6c90f78d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/anaphan1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e34a63831bd28a03b05cc0a6010cfe2e6c90f78d -
Trigger Event:
release
-
Statement type: