首次提交
This commit is contained in:
14
auto_generator.py
Normal file
14
auto_generator.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# 自动生成数据库表和sqlalchemy对应的Model
|
||||
import subprocess
|
||||
|
||||
from config.mysql import DB_URL
|
||||
|
||||
table = input("请输入表名:")
|
||||
out_file = f"photo_review/entity/{table}.py"
|
||||
command = f"sqlacodegen {DB_URL} --outfile={out_file} --tables={table}"
|
||||
|
||||
try:
|
||||
subprocess.run(command, shell=True, check=True)
|
||||
print(f"{table}.py文件生成成功!请手动调整Base的声明!")
|
||||
except Exception as e:
|
||||
print(f"生成{table}.py文件时发生错误: {e}")
|
||||
Reference in New Issue
Block a user