patera-database
Async SQLAlchemy integration for Patera: databases, request sessions, repositories and transactions. Part of Patera, a modular async-first Python web framework.
Installation
pip install patera-database
# or, with uv
uv add "patera[database]"
Requires Python 3.13 or newer and patera>=0.121.
Usage
patera-database integrates async SQLAlchemy. Install a driver for your database too
(aiosqlite is included; e.g. asyncpg for PostgreSQL).
# app/database.py
from sqlalchemy import Integer, String
from sqlalchemy.orm import Mapped, mapped_column
from patera.database.sql import DeclarativeBaseModel, SqlDatabase, SqlDatabaseManager
class MainDb(SqlDatabase):
__db_name__ = "main"
class Databases(SqlDatabaseManager):
databases = [MainDb]
class Base(DeclarativeBaseModel):
__abstract__ = True
__db_name__ = "main" # models are bound to a database by name
class Note(Base):
__tablename__ = "notes"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
title: Mapped[str] = mapped_column(String(200))
See the SQL databases section of the Patera documentation for the full guide.
License
MIT. See LICENSE.
Metadata
Release files for patera-database 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| patera_database-0.11.0.tar.gz | 17.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| patera_database-0.11.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.1 kB
Release files / patera_database-0.11.0.tar.gz
| Download URL | patera_database-0.11.0.tar.gz |
|---|---|
| Size | 17.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df44e8026d1161b577820c4d2571e665318595b1070e22c198748106f5c2ee79
|
|
BLAKE2b-256 checksum How to use checksums |
73b163b9e0728658617766f35b15fcf0414ebe74f8d843e61db58ea8cfdee5f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / patera_database-0.11.0-py3-none-any.whl
| Download URL | patera_database-0.11.0-py3-none-any.whl |
|---|---|
| Size | 22.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26ffd9c09956cbb61dbbe03d7901d2915cbd5a2263229831ddfdd5423e5e9508
|
|
BLAKE2b-256 checksum How to use checksums |
c03da0ff5a0a735ebf0845b15aa4b56ed47c158a68defe06deb78fad395e551f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|