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
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |