You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
398 B
Python

from sqlmodel import SQLModel
from entity import DbBaseModel, engine
# 初始化数据库表(异步执行)
async def init_db():
async with engine.begin() as conn:
await conn.run_sync(SQLModel.metadata.create_all)
class User(DbBaseModel, table=True):
__tablename__ = "user" # 可以显式指定数据库表名,默认实体名转小写
username: str
password: str