Skip to main content

A base framework for a plug-and-play ORM

Project description

PlugORM

PyPI version Python versions License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plugorm-0.2.0.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plugorm-0.2.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

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

Hashes for plugorm-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a375348e2fe6db21668270c57cf6105bba695aee4c86d1b919ad0c187807b55b
MD5 4ca40875e7ca8357ca57b2200e3cde07
BLAKE2b-256 6849c860de8ec75d7d947c86cbce9956bebdf3ad72ad80658a64973561ba487e

See more details on using hashes here.

Provenance

The following attestation bundles were made for plugorm-0.2.0.tar.gz:

Publisher: python-publish.yml on anaphan1/plugorm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for plugorm-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 841640755206ca1db7cf9d4856f434d8d923e4c53279acd81205eaea6d8335ab
MD5 b5ae9430f43e0f7d57ae7ebee35fe59d
BLAKE2b-256 9de0963ecdcd7fdc435cb09234fdaf896bc04345a2aa1c0b1f420b160a291842

See more details on using hashes here.

Provenance

The following attestation bundles were made for plugorm-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on anaphan1/plugorm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page