Spaces:
Runtime error
Runtime error
Download src/entities/base/_model.py from sifars/firermsdata-agent: direct link, hf CLI and curl.
- Browser
- Download file 860 Bytes
-
https://huggingface.co/spaces/sifars/firermsdata-agent/resolve/main/src/entities/base/_model.py
- Command line
-
hf download hf://spaces/sifars/firermsdata-agent/src/entities/base/_model.py
-
curl -L -o _model.py https://huggingface.co/spaces/sifars/firermsdata-agent/resolve/main/src/entities/base/_model.py
860 Bytes
| from datetime import datetime, date | |
| from sqlalchemy import BigInteger, Column, DateTime, func | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.inspection import inspect | |
| Base = declarative_base() | |
| class BaseModel_(Base): | |
| __abstract__ = True # This model should not be instantiated directly | |
| __table_args__ = {"extend_existing": True} # Allow table extension | |
| created = Column(DateTime, server_default=func.now(), nullable=False) | |
| def to_dict(self, keys_not_to_include: list[str] = []) -> dict: | |
| return { | |
| c.key: ( | |
| getattr(self, c.key).isoformat() | |
| if isinstance(getattr(self, c.key), (datetime, date)) | |
| else getattr(self, c.key) | |
| ) | |
| for c in inspect(self).mapper.column_attrs | |
| if c.key not in keys_not_to_include | |
| } |