21 lines
664 B
Python
21 lines
664 B
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, Integer
|
|
from sqlalchemy.orm import declarative_base, Mapped, mapped_column
|
|
from text_unidecode import unidecode
|
|
|
|
from fuware.db.db_setup import SessionLocal
|
|
|
|
Model = declarative_base()
|
|
Model.query = SessionLocal.query_property()
|
|
|
|
class SqlAlchemyBase(Model):
|
|
__abstract__ = True
|
|
|
|
created_at: Mapped[datetime | None] = mapped_column(DateTime, default=datetime.utcnow(), index=True)
|
|
update_at: Mapped[datetime | None] = mapped_column(DateTime, default=datetime.utcnow(), onupdate=datetime.utcnow())
|
|
|
|
@classmethod
|
|
def normalize(cls, val: str) -> str:
|
|
return unidecode(val).lower().strip()
|