bag.sqlalchemy.created_changed module

SQLAlchemy trick that makes it easy to implement timestamp columns.

Usage:

from bag.sqlalchemy.created_changed import created_changed, CreatedChanged

@created_changed
class MyModel(BaseModel, CreatedChanged):
    ...
class bag.sqlalchemy.created_changed.CreatedChanged[source]

Bases: object

Mixin class that adds created and changed columns.

Must be used together with the @created_changed class decorator.

changed = Column(None, DateTime(), table=None, nullable=False)
created = Column(None, DateTime(), table=None, nullable=False)
bag.sqlalchemy.created_changed.created_changed(cls)[source]

Decorate cls to update created and changed automatically.

If you use SQLAlchemy inheritance, apply this decorator to subclasses.