Collection of SQLAlchemy mixins
Project description
Bixomix
bixomix is a collection of SQLAlchemy mixins.
Support
- Python 3.9+
- SQLAlchemy 2.0+
Install
pip install bixomix
Usage
Add mixins after the Base
class in each model’s parent classes. The order of the mixins doesn’t matter.
from sqlalchemy.orm import DeclarativeBase
from bixomix import CreatedAtMixin, EnabledMixin
class Base(DeclarativeBase):
pass
class MyModel(Base, CreatedAtMixin, EnabledMixin):
# Add your own fields here
...
Mixins
CreatedAtMixin
: add acreated_at
datetime field that’s automatically filled with the record’s creation dateUpdatedAtMixin
: add anupdated_at
datetime field that’s automatically filled with the record’s last update date. Note that on Postgres this is done in Python; for a database-level update you have to create a trigger.CreatedUpdatedAtMixin
: combined version of the previous two mixinsEnabledMixin
: add anenabled
boolean field (default istrue
)EnabledNoMixin
: same asEnabledMixin
, but the default value isfalse
UpdateFromDictMixin
: add anupdate_from_dict
method to update a model in-place given a dictionary of attributes
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
bixomix-0.1.2.tar.gz
(3.3 kB
view details)
Built Distribution
File details
Details for the file bixomix-0.1.2.tar.gz
.
File metadata
- Download URL: bixomix-0.1.2.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.16 Linux/6.5.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24db5a37a3e5cc1324910d8cd36f2aa7e403b8c2fe2f0b145bc9257bf02a30e1 |
|
MD5 | 3ddf9fdba23efef6c56f044f368c40cd |
|
BLAKE2b-256 | 1b966b1a1c3e27119f54bc75a98a21d10ba225d07a59a38a93d6bc5141d53ca7 |
File details
Details for the file bixomix-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: bixomix-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.16 Linux/6.5.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97665a0234703425877d2a1a29b78615cfd1048f41ce71353c2f2cdb776936d6 |
|
MD5 | f7acfdf3689f9105956b05b98ce1bb8c |
|
BLAKE2b-256 | 417017f359b9e3bf25b8763187e7ee72f31843737767fff3ed0e9cad80b29acc |