Skip to main content

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


Download files

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

Source Distribution

unboil_sqlalchemy_mixins-0.1.14.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

unboil_sqlalchemy_mixins-0.1.14-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file unboil_sqlalchemy_mixins-0.1.14.tar.gz.

File metadata

File hashes

Hashes for unboil_sqlalchemy_mixins-0.1.14.tar.gz
Algorithm Hash digest
SHA256 d3084f13833f83be3306e211c229bbbff89c8e94bd3b0d44379ad8b5a490605f
MD5 beaa24aab9f45643740feb7707058a02
BLAKE2b-256 cd112b46ad1f7555d54d7507ac0ed48ad0b18b5bc4c2e7b2b482d3c9ea031c5e

See more details on using hashes here.

File details

Details for the file unboil_sqlalchemy_mixins-0.1.14-py3-none-any.whl.

File metadata

File hashes

Hashes for unboil_sqlalchemy_mixins-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 9a3aa4390a073696dce593923b3e0e26fe7256143a4253b43adda7b551472e59
MD5 501a24bd0422d96d56c312746613bee9
BLAKE2b-256 2da5a0de7836248b0ea3e431900bbdb9e62ea763a0ef9c858a1622a5f7d8a538

See more details on using hashes here.

Supported by

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