simple_module_db
Database layer for the simple_module framework. Provides a per-module Base, an async SQLAlchemy/SQLModel session, standard mixins, and an auto-commit-on-flush listener that removes manual session.commit() calls from service code.
Install
pip install simple_module_db
What it provides
create_module_base("<module_name>")— a module-scoped declarativeBasewith its ownMetaData. All modules share the host's single schema, so__tablename__should be prefixed with the module name (e.g.users_user) to avoid collisions.- Per-request
RequestSession(get_db) that commits pending writes before the response and rolls back read-only requests. session.on_commit(callback)for synchronous or asynchronous cache refreshes that must only run after a successful request commit.- Mixins in
simple_module_db.mixins:AuditMixin(created_at/updated_at),SoftDeleteMixin(auto-filtered unlessstmt.execution_options(include_deleted=True)),MultiTenantMixin,VersionedMixin. DatabaseStatecontainer used by the framework to avoid global mutable state.
Usage
# modules/orders/orders/models.py
from simple_module_db import AuditMixin, SoftDeleteMixin, create_module_base
from sqlmodel import Field
Base = create_module_base("orders")
class Order(Base, AuditMixin, SoftDeleteMixin, table=True):
id: int | None = Field(default=None, primary_key=True)
customer_id: int = Field(index=True, foreign_key="users_user.id")
total_cents: int
In a service:
from simple_module_db import RequestSession, get_db
async def create_order(session: RequestSession = Depends(get_db), ...):
order = Order(customer_id=..., total_cents=...)
session.add(order)
await session.flush() # assigns order.id; commit happens before the response
session.on_commit(order_cache.refresh)
return order
Never call session.commit() — the framework handles it.
Depends on
simple_module_core,sqlalchemy[asyncio],sqlmodel,alembic,asyncpg,aiosqlite
License
MIT — see LICENSE.
Metadata
Release files for simple-module-db 0.0.36
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 | |
|---|---|---|---|---|
| simple_module_db-0.0.36.tar.gz | 64.9 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| simple_module_db-0.0.36-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 111.4 kB
Release files / simple_module_db-0.0.36.tar.gz
| Download URL | simple_module_db-0.0.36.tar.gz |
|---|---|
| Size | 64.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39ed5673aa48aeb6ec1184735bed10367ef8a1272f7dab2d36cbd22ca418ef05
|
|
BLAKE2b-256 checksum How to use checksums |
00d86b7e4bd56860cbdabe99e5d23cfcd867d437539e8748ea1905a1f34a27b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / simple_module_db-0.0.36-py3-none-any.whl
| Download URL | simple_module_db-0.0.36-py3-none-any.whl |
|---|---|
| Size | 46.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b6bf62eba76a2a1b13e46cf0baaa6e4ba9c08be9d4847631d9eb1d0382cbd08
|
|
BLAKE2b-256 checksum How to use checksums |
3a60e3e28790a514cdf71f2b4e9ad91a0c9c8c7a716cf42849b1df50eafc9e68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logSecurity for simple-module-db 0.0.36
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for simple_module_db-0.0.36.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logA 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.