INNER CODE UNIT · Python

TableMixin

c0sogi/LLMChat · app/database/schemas/__init__.py:13

class TableMixin:
    id: Mapped[int] = mapped_column(primary_key=True)
    created_at: Mapped[datetime] = mapped_column(default=func.utc_timestamp())
    updated_at: Mapped[datetime] = mapped_column(
        default=func.utc_timestamp(),
        onupdate=func.utc_timestamp(),
    )
    ip_address: Mapped[str | None] = mapped_column(String(length=40))

    def set_values_as(self, **kwargs):
        for key, value in kwargs.items():
            setattr(self, key, value)

    def to_dict(self, *args, exclude: list | None = None):
        q_dict: dict = {}
        for c in self.__table__.columns:  # type: ignore
            if not args or c.name in args:
                if not exclude or c.name not in exclude:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…