This commit is contained in:
vipg
2025-12-26 16:33:11 +08:00
parent 5cee27cb72
commit 586ee37bf3
3 changed files with 9 additions and 6 deletions

View File

@@ -7,8 +7,8 @@ create.py - 动态生成PostgreSQL建表SQL语句
import os
import re
# 1. 定义表名称变量,方便调整
table_name = "cn_pmi_234_aaarecords" # 可以根据需要修改表名
# 从环境变量获取表名,如果没有设置则使用默认值
table_name = os.environ.get('TABLE_NAME', 'cn_pmi_234_aaarecords')
# 2. 定义SQL模板
sql_template = f"""DO $$
@@ -69,7 +69,7 @@ def update_sql_file():
with open(sql_file_path, 'r', encoding='utf-8') as f:
content = f.read()
# 查找插入位置(在\"部署完成\"日志前)
# 查找插入位置(在"部署完成"日志前)
insert_pattern = r'(DO \$\$.*?RAISE NOTICE \'🚀============ 数据库表部署开始 ============🚀\'.*?END \$\$;)(.*?)(DO \$\$.*?RAISE NOTICE \'============ 数据库表部署完成 ============\'.*?END \$\$;)'
match = re.search(insert_pattern, content, re.DOTALL)