sqlmodel:如何使用自定义表名

在你的 SQLModel 子类中设置 __tablename__ 来定义自定义表名。

sqlmodel_custom_tablename.py

class Product(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    mpn: Optional[str] = Field(description="Manufacturer part number", index=True)

    __tablename__ = "MyApplicationProduct"

Check out similar posts by category: SQLModel, Python