|
@@ -4,29 +4,57 @@ import pandas as pd
|
|
|
import time
|
|
|
from sqlalchemy import create_engine
|
|
|
import os
|
|
|
+import configparser
|
|
|
import pymysql
|
|
|
import traceback
|
|
|
import datetime
|
|
|
-from LIB.BACKEND import DBManager,Log # 以相对路径的方式引入!!!!!
|
|
|
-from V_1_0_0 import core # 以相对路径的方式引入!!!!!
|
|
|
+from LIB.BACKEND import DBManager,Log # 以相对路径的方式从LIB开始引入!!!!!
|
|
|
+from LIB.MIDDLE.AlgoTest.Algo1.V_1_0_0.CoreAlgo import core # 以相对路径的方式从LIB开始引入!!!!!
|
|
|
from LIB.BACKEND.OPENAPI import OpenApi
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
- # 环境变量配置(通过环境变量接收数据库等相关配置参数)
|
|
|
+ # 环境变量配置(通过环境变量确定当前程序运行在开发、测试、生产环境)
|
|
|
env_dist = os.environ
|
|
|
- host1 = env_dist.get("HOST1", '127.0.0.1')
|
|
|
- port1 = int(env_dist.get("PORT1", '3306'))
|
|
|
- db1 = env_dist.get("DB1", 'test')
|
|
|
- user1 = env_dist.get("USER1", 'root')
|
|
|
- password1 = env_dist.get("PASSWORD1", 'Qx123456')
|
|
|
+ cur_env = env_dist.get("CURENV", 'dev') # 默认为开发环境
|
|
|
|
|
|
- host2 = env_dist.get("HOST2", '127.0.0.1')
|
|
|
- port2 = int(env_dist.get("PORT2", '3306'))
|
|
|
- db2 = env_dist.get("DB2", 'test')
|
|
|
- user2 = env_dist.get("USER2", 'root')
|
|
|
- password2 = env_dist.get("PASSWORD2", 'Qx123456')
|
|
|
+ # 读取配置文件
|
|
|
+ cf = configparser.ConfigParser()
|
|
|
+ if cur_env == 'dev':
|
|
|
+ cf.read("config-dev.ini")
|
|
|
+ elif cur_env == 'test':
|
|
|
+ cf.read("config-test.ini")
|
|
|
+ elif cur_env == 'pro':
|
|
|
+ cf.read("config-pro.ini")
|
|
|
+
|
|
|
+ options = cf.options("Mysql-1")
|
|
|
+ items = cf.items("Mysql-1")
|
|
|
+ print(options)
|
|
|
+ print(items)
|
|
|
+
|
|
|
+ host1 = cf.get("Mysql-1", 'host')
|
|
|
+ port1 = int(cf.get("Mysql-1", 'port'))
|
|
|
+ db1 = cf.get("Mysql-1", 'db')
|
|
|
+ user1 = cf.get("Mysql-1", 'user')
|
|
|
+ password1 = cf.get("Mysql-1", 'password')
|
|
|
+
|
|
|
+ host2 = cf.get("Mysql-2", 'host')
|
|
|
+ port2 = int(cf.get("Mysql-2", 'port'))
|
|
|
+ db2 = cf.get("Mysql-2", 'db')
|
|
|
+ user2 = cf.get("Mysql-2", 'user')
|
|
|
+ password2 = cf.get("Mysql-2", 'password')
|
|
|
+ # host1 = env_dist.get("HOST1", '127.0.0.1')
|
|
|
+ # port1 = int(env_dist.get("PORT1", '3306'))
|
|
|
+ # db1 = env_dist.get("DB1", 'test')
|
|
|
+ # user1 = env_dist.get("USER1", 'root')
|
|
|
+ # password1 = env_dist.get("PASSWORD1", 'Qx123456')
|
|
|
+
|
|
|
+ # host2 = env_dist.get("HOST2", '127.0.0.1')
|
|
|
+ # port2 = int(env_dist.get("PORT2", '3306'))
|
|
|
+ # db2 = env_dist.get("DB2", 'test')
|
|
|
+ # user2 = env_dist.get("USER2", 'root')
|
|
|
+ # password2 = env_dist.get("PASSWORD2", 'Qx123456')
|
|
|
|
|
|
# 日志配置(按照该配置,每次运行时可自动生成运行日期的文件夹, 会在与main同级的)
|
|
|
now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
|