20 lines
587 B
Python
20 lines
587 B
Python
import asyncio
|
|
from app.db.database import Base, engine
|
|
from app.models.users import User
|
|
from app.models.person_images import PersonImage
|
|
from app.models.clothing import ClothingCategory, Clothing
|
|
|
|
# 创建所有表格
|
|
async def init_db():
|
|
async with engine.begin() as conn:
|
|
# 在SQLAlchemy 2.0中可以直接使用异步创建表
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
|
|
# 同步入口点
|
|
def init_db_sync():
|
|
asyncio.run(init_db())
|
|
|
|
if __name__ == "__main__":
|
|
print("创建数据库表...")
|
|
init_db_sync()
|
|
print("数据库表创建完成。") |