31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
# @Time : 2025/3/15 22:57
|
|
# @Author : AngesZhu
|
|
# @File : get_db_config.py
|
|
# @Desc : 获取数据库配置
|
|
from utils.path_utils import PathOperator
|
|
from utils.yaml_utils import YAMLOperator
|
|
from utils.logger_utils import logger
|
|
|
|
|
|
def get_db_config(env):
|
|
|
|
logger.info(f"数据库连接配置获取, 获取环境:{env}")
|
|
path_operator = PathOperator()
|
|
base_path = path_operator.get_parent_path(path_operator.get_full_path())
|
|
field_rules_path = path_operator.join_path(base_path, "config")
|
|
|
|
match env:
|
|
case "test":
|
|
yaml_operator = YAMLOperator("{}/{}".format(field_rules_path, "test_sql_config.yaml"))
|
|
return True, yaml_operator.data
|
|
case "dev":
|
|
yaml_operator = YAMLOperator("{}/{}".format(field_rules_path, "test_sql_config.yaml"))
|
|
return True, yaml_operator.data
|
|
case "uat":
|
|
yaml_operator = YAMLOperator("{}/{}".format(field_rules_path, "test_sql_config.yaml"))
|
|
return True, yaml_operator.data
|
|
case _:
|
|
return False, "Env Error"
|