from configparser import ConfigParser import os ENVIRONMENT_VARIABLE = os.getenv("ENVIRONMENT_VARIABLE", "test") def get_path(): current_directory = os.path.dirname(os.path.abspath(__file__)) root_path = os.path.abspath(os.path.dirname(current_directory) + os.path.sep + ".") return root_path def get_pg_config(): conf = ConfigParser() conf.read(get_path() + '/config/config.ini') return { "database": conf[ENVIRONMENT_VARIABLE]['database'], "user": conf[ENVIRONMENT_VARIABLE]['user'], "password": conf[ENVIRONMENT_VARIABLE]['password'], "host": conf[ENVIRONMENT_VARIABLE]['host'], "port": conf[ENVIRONMENT_VARIABLE]['port'], # 设置默认超时时间statement_timeout=五分钟 "options":"-c statement_timeout=800000 -c idle_in_transaction_session_timeout=900000" } if __name__ == '__main__': print(get_path())