A library providing reusable mixins for SQLAlchemy models.
Project description
unboil-sqlalchemy-mixins
Reusable SQLAlchemy mixins to reduce boilerplate in your Python ORM models.
Installation
pip install unboil-sqlalchemy-mixins
Mixins
IdentifiableMixin
Adds a string id
primary key. Optionally, use a prefix:
from unboil_sqlalchemy_mixins import IdentifiableMixin
class User(IdentifiableMixin, Base): ...
# With prefix:
class PrefixedUser(IdentifiableMixin.with_id_prefix("user_"), Base): ...
TimestampedMixin
Adds created_at
and updated_at
fields (auto-managed):
from unboil_sqlalchemy_mixins import TimestampedMixin
class Post(TimestampedMixin, Base): ...
TenantOwnedMixin
Adds a required, indexed tenant_id
column. Optionally, specify a foreign key:
from unboil_sqlalchemy_mixins import TenantOwnedMixin
class Invoice(TenantOwnedMixin, Base): ...
# With foreign key:
class InvoiceWithFK(TenantOwnedMixin.with_tenant_fk("tenants.id"), Base): ...
UserOwnedMixin
Adds a required, indexed user_id
column. Optionally, specify a foreign key:
from unboil_sqlalchemy_mixins import UserOwnedMixin
class Note(UserOwnedMixin, Base): ...
# With foreign key:
class NoteWithFK(UserOwnedMixin.with_user_fk("users.id"), Base): ...
MIT License
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
File details
Details for the file unboil_sqlalchemy_mixins-0.1.14.tar.gz
.
File metadata
- Download URL: unboil_sqlalchemy_mixins-0.1.14.tar.gz
- Upload date:
- Size: 29.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
d3084f13833f83be3306e211c229bbbff89c8e94bd3b0d44379ad8b5a490605f
|
|
MD5 |
beaa24aab9f45643740feb7707058a02
|
|
BLAKE2b-256 |
cd112b46ad1f7555d54d7507ac0ed48ad0b18b5bc4c2e7b2b482d3c9ea031c5e
|
File details
Details for the file unboil_sqlalchemy_mixins-0.1.14-py3-none-any.whl
.
File metadata
- Download URL: unboil_sqlalchemy_mixins-0.1.14-py3-none-any.whl
- Upload date:
- Size: 5.2 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 |
9a3aa4390a073696dce593923b3e0e26fe7256143a4253b43adda7b551472e59
|
|
MD5 |
501a24bd0422d96d56c312746613bee9
|
|
BLAKE2b-256 |
2da5a0de7836248b0ea3e431900bbdb9e62ea763a0ef9c858a1622a5f7d8a538
|