Object-relational mapping¶
fastsqla.Base¶
Bases: DeclarativeBase, DeferredReflection
Inherit from Base to declare an SQLAlchemy model.
Example:
from fastsqla import Base
from sqlalchemy.orm import Mapped, mapped_column
class Hero(Base):
__tablename__ = "hero"
id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(unique=True)
secret_identity: Mapped[str]
age: Mapped[int]
To learn more on SQLAlchemy ORM & Declarative mapping:
Note
You don't need this if you use SQLModel.
Source code in src/fastsqla.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |