Object-relational mapping¶
fastsqla.Base
¶
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: