Skip to main content

An opinionated, modern ORM for Python combining the power of SQLAlchemy 2.0 with a clean, symmetrical API for sync and async operations.

Project description

DuoORM

PyPI version Python versions Docs

An opinionated ORM with symmetrical sync/async APIs, explicit unit-of-work control, and ready-to-use Alembic scaffolding. DuoORM manages drivers for you—use driverless URLs like postgresql://... or sqlite:///app.db and it wires up the correct sync/async engines under the hood (SQLAlchemy 2.x).

Highlights

  • One API for sync and async (add await when needed).
  • Explicit unit of work: single-statement by default; opt into db.transaction() for shared sessions and cascades.
  • Driverless URLs; DuoORM injects the right sync/async driver per dialect.
  • Import common SQLAlchemy types and helpers directly from duo_orm (e.g., String, JSON, PG_ARRAY, text, func).
  • Built-in Alembic CLI scaffolding and migration commands.
  • Tested across PostgreSQL, MySQL, MSSQL, Oracle, and SQLite (coverage matrix).

Install

pip install duo-orm                  # core + sqlite drivers
pip install "duo-orm[postgresql]"    # psycopg (sync+async)
pip install "duo-orm[mysql]"         # pymysql + asyncmy
pip install "duo-orm[mssql]"         # pyodbc + aioodbc
pip install "duo-orm[oracle]"        # oracledb (sync+async)
pip install "duo-orm[all]"           # install everything

SQLite fallback (only if your Python lacks stdlib sqlite3, e.g., minimal Docker/Lambda):

pip install pysqlite3-binary
python - <<'PY'
import sys, pysqlite3
sys.modules["sqlite3"] = pysqlite3
PY

Quickstart

from duo_orm import Database, Mapped, mapped_column, String

db = Database("sqlite:///./app.db")  # driverless URL

class User(db.Model):
    __tablename__ = "users"
    id: Mapped[int] = mapped_column(primary_key=True)
    name: Mapped[str] = mapped_column(String(100))

# One-shot (single statement/session)
user = User.where(User.name == "Ada").first()

# Transactional work (shared session)
async def create_user():
    async with db.transaction():
        u = User(name="New")
        await u.save()

# When you're done (scripts/CLIs), optionally tear down engines
db.disconnect()

Engine lifecycle helpers

  • db.connect() eagerly initializes sync/async engines so misconfiguration surfaces early (optional; engines still initialize lazily).
  • db.disconnect() disposes any initialized engines and clears cached factories; use it at the end of scripts/CLIs to release pools explicitly. Context managers (db.transaction(), standalone_session(), sync_standalone_session()) already close sessions on exit.

Documentation

License

MIT

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

duo_orm-0.1.1.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

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

duo_orm-0.1.1-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file duo_orm-0.1.1.tar.gz.

File metadata

  • Download URL: duo_orm-0.1.1.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for duo_orm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0a22ce0df17bf8c842003d1ffd223e80cd359a7e55f8b24c70a1624b59c3cc77
MD5 2faacbb6eb4febaa751ca8792dff6529
BLAKE2b-256 1182e12590cc2bcf0ccf2ff51ca278d6c0a9ae5a1f60e0995f0d0dbce085dae2

See more details on using hashes here.

File details

Details for the file duo_orm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: duo_orm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for duo_orm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 750b6477b561dd718da5693f100c49644824f79f06eb97c639a3a834e00c3790
MD5 ce1a2fb5a1fe12c48dafd1b3600c3d34
BLAKE2b-256 5cd570161c208a2d4e23d91566617e427593c2f52f47b59ce4e39f01c5b04a2c

See more details on using hashes here.

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