统一引号格式,优化架构排布

This commit is contained in:
2024-09-26 15:16:57 +08:00
parent ff9d612e67
commit c5a03ad16f
22 changed files with 143 additions and 302 deletions

19
tool/auto_generator.py Normal file
View File

@@ -0,0 +1,19 @@
"""
自动生成数据库表和sqlalchemy对应的Model
"""
import os.path
import subprocess
from db import DB_URL
from log import PROJECT_ROOT
if __name__ == '__main__':
table = input('请输入表名:')
out_file = os.path.join(PROJECT_ROOT, 'db', f'{table}.py')
command = f'sqlacodegen {DB_URL} --outfile={out_file} --tables={table}'
try:
subprocess.run(command, shell=True, check=True)
print(f'{table}.py文件生成成功请检查并复制到合适的文件中')
except Exception as e:
print(f'生成{table}.py文件时发生错误: {e}')