feat: 添加测试用户到种子数据, AI改写功能优化, 前端联调修复
This commit is contained in:
@@ -9,12 +9,25 @@ from pathlib import Path
|
||||
# 获取当前脚本所在目录
|
||||
SQL_DIR = Path(__file__).parent
|
||||
|
||||
# 数据库配置(从环境变量或默认值)
|
||||
# 从.env文件读取配置
|
||||
def load_env():
|
||||
env_file = SQL_DIR.parent / '.env'
|
||||
config = {}
|
||||
if env_file.exists():
|
||||
for line in env_file.read_text(encoding='utf-8').splitlines():
|
||||
if '=' in line and not line.startswith('#'):
|
||||
k, v = line.split('=', 1)
|
||||
config[k.strip()] = v.strip()
|
||||
return config
|
||||
|
||||
env_config = load_env()
|
||||
|
||||
# 数据库配置(优先从.env读取)
|
||||
DB_CONFIG = {
|
||||
'host': os.getenv('DB_HOST', 'localhost'),
|
||||
'port': int(os.getenv('DB_PORT', 3306)),
|
||||
'user': os.getenv('DB_USER', 'root'),
|
||||
'password': os.getenv('DB_PASSWORD', '123456'),
|
||||
'host': env_config.get('DB_HOST', os.getenv('DB_HOST', 'localhost')),
|
||||
'port': int(env_config.get('DB_PORT', os.getenv('DB_PORT', 3306))),
|
||||
'user': env_config.get('DB_USER', os.getenv('DB_USER', 'root')),
|
||||
'password': env_config.get('DB_PASSWORD', os.getenv('DB_PASSWORD', '')),
|
||||
'charset': 'utf8mb4'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user