fix:修复了环境变量中的数据库账户密码无法成功导入的错误。增加相关依赖python-dotenv>=1.0.0

This commit is contained in:
2026-07-31 22:13:16 +08:00
parent 94c8305d9c
commit 7612bae51e
3 changed files with 25 additions and 5 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ from psycopg2 import sql
from psycopg2.extras import execute_values
from sqlalchemy import create_engine
from config import DB_CONFIG, TUSHARE_TOKEN, BATCH_SIZE, START_DATE, END_DATE
from config import DB_CONFIG, TUSHARE_TOKEN, BATCH_SIZE, START_DATE, END_DATE, PASSWORD_ENCODED
# ============================================================
# 日志配置
@@ -55,7 +55,7 @@ def get_sqlalchemy_engine():
global _sqlalchemy_engine
if _sqlalchemy_engine is None:
db_url = (
f"postgresql://{DB_CONFIG['user']}:{DB_CONFIG['password']}"
f"postgresql://{DB_CONFIG['user']}:{PASSWORD_ENCODED}"
f"@{DB_CONFIG['host']}:{DB_CONFIG['port']}/{DB_CONFIG['database']}"
)
_sqlalchemy_engine = create_engine(db_url, pool_size=5, max_overflow=10)