Skip to main content

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 a created_at datetime field that’s automatically filled with the record’s creation date
  • UpdatedAtMixin: add an updated_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 mixins
  • EnabledMixin: add an enabled boolean field (default is true)
  • EnabledNoMixin: same as EnabledMixin, but the default value is false
  • UpdateFromDictMixin: add an update_from_dict method to update a model in-place given a dictionary of attributes

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

bixomix-0.1.1.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

bixomix-0.1.1-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

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