fix: 清除硬编码API Key与机器特定路径,改用环境变量+混合式路径解析
This commit is contained in:
+8
-3
@@ -33,6 +33,11 @@ from runners.gixsql_runner import GixsqlCobolRunner, GixsqlTableData
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# DB 管道 SQLite 存放目录。默认保持短 ASCII 路径:
|
||||
# COBOL CONNECT TO 字符串受固定格式第 72 列限制,且 gixpp 无法处理中文路径。
|
||||
# 可用环境变量 GIXSQL_DB_DIR 覆盖(见 .env.example)。
|
||||
GIXSQL_DB_DIR = Path(os.environ.get("GIXSQL_DB_DIR", "C:/Temp/gix"))
|
||||
|
||||
|
||||
def _calc_birth_date(age: int, as_of: str = '20260802') -> str:
|
||||
"""年龄 → 出生日期 YYYYMMDD(通用)。as_of 为运行时运用日。"""
|
||||
@@ -103,8 +108,8 @@ class GixsqlOrchestrator:
|
||||
compile_flags=config.gixsql_compile_flags,
|
||||
)
|
||||
|
||||
# Derive DB path: C:\Temp\gix\<program_id>.db (matches COBOL CONNECT TO, short enough for col 72)
|
||||
self.db_path = Path("C:/Temp/gix") / f"{self.program_id}.db"
|
||||
# Derive DB path: <GIXSQL_DB_DIR>\<program_id>.db (matches COBOL CONNECT TO, short enough for col 72)
|
||||
self.db_path = GIXSQL_DB_DIR / f"{self.program_id}.db"
|
||||
|
||||
# Pipeline state
|
||||
self.src_path: Optional[Path] = None
|
||||
@@ -263,7 +268,7 @@ class GixsqlOrchestrator:
|
||||
|
||||
# シナリオに応じた DB パス
|
||||
if scenario:
|
||||
db_path = Path("C:/Temp/gix") / f"{self.program_id}_{scenario.id}.db"
|
||||
db_path = GIXSQL_DB_DIR / f"{self.program_id}_{scenario.id}.db"
|
||||
self._current_db_path = db_path
|
||||
else:
|
||||
db_path = self.db_path
|
||||
|
||||
Reference in New Issue
Block a user