依赖Pydantic,SQLAlchemy 数据库模型扩展 https://github.com/tiangolo/sqlmodel

天问 8fcf0a5efc Update 'README.md' 9 months ago
README.md 8fcf0a5efc Update 'README.md' 9 months ago

README.md

sqlmodel

依赖Pydantic,SQLAlchemy 数据库模型扩展

Usage

定义一个表:

from typing import Optional
from sqlmodel import Field, SQLModel

class Hero(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    name: str
    secret_name: str
    age: Optional[int] = None

插入表:

hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")