12 lines
446 B
Python
12 lines
446 B
Python
from api_server import Base, engine
|
|
|
|
print("连接数据库 ...")
|
|
# 从 api_server.py 导入 Base (包含了所有模型) 和 engine (数据库连接)
|
|
|
|
print("创建表(如果表不存在)...")
|
|
# create_all 默认会检查表是否存在 (checkfirst=True),所以重复运行是安全的
|
|
# 但我们只在需要时手动运行它
|
|
Base.metadata.create_all(bind=engine, checkfirst=True)
|
|
|
|
print("数据表创建成功(或已经存在)。")
|