# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test63_idea
# FileName:      Readbasicini.py
# Author:       Jing
# Datetime:     2024/11/5 19:30
# Description:
# 
# ---------------------------------------------------------------------------
import os
import configparser
from v3 import log

class Readbasicini:
    def __init__(self):
        self.data_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data")
        ini_path = os.path.join(self.data_path, "basic_config.ini")
        self.conf = configparser.ConfigParser()
        self.conf.read(ini_path, encoding="utf-8")

    def get_host(self, key):
        log.info(f"执行get_host方法，传入的参数为{key}")
        try:
            return self.conf.get("host", key)
        except Exception as e:
            log.error(f'主机Key有问题，具体错误为{e}，错误类型是{type(e)}')

    def get_sql_msg(self, key):
        log.info(f"执行get_sql_msg方法获取sql节点下的数据库信息，传入的参数为{key}")
        try:
            return self.conf.get("sql", key)
        except Exception as e:
            log.info(f"数据库Key有问题,具体错误为{e}，错误类型是{type(e)}")
            raise e



if __name__ == '__main__':
    ini = Readbasicini()