|
@@ -9,10 +9,16 @@ import yaml
|
|
import os
|
|
import os
|
|
import pandas as pd
|
|
import pandas as pd
|
|
from clickhouse_driver.client import Client
|
|
from clickhouse_driver.client import Client
|
|
-import json
|
|
|
|
log = logger()
|
|
log = logger()
|
|
|
|
|
|
|
|
|
|
|
|
+def db_config():
|
|
|
|
+ p_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
|
|
|
+ path = os.path.join(p_path, "config", "db_config.yaml")
|
|
|
|
+ f = open(path, encoding="utf-8")
|
|
|
|
+ config = yaml.load(f.read(), Loader=yaml.FullLoader)
|
|
|
|
+ return config
|
|
|
|
+
|
|
class MysqlUtils:
|
|
class MysqlUtils:
|
|
_quchen_text = None
|
|
_quchen_text = None
|
|
_zx=None
|
|
_zx=None
|
|
@@ -21,14 +27,7 @@ class MysqlUtils:
|
|
_zx_test =None
|
|
_zx_test =None
|
|
|
|
|
|
def __init__(self):
|
|
def __init__(self):
|
|
- p_path =os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
|
|
|
- path = os.path.join(p_path,"config", "db_config.yaml")
|
|
|
|
- f = open(path, encoding="utf-8")
|
|
|
|
- self.config = yaml.load(f.read(), Loader=yaml.FullLoader)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ self.config = db_config()
|
|
|
|
|
|
@property
|
|
@property
|
|
def quchen_text(self):
|
|
def quchen_text(self):
|
|
@@ -111,10 +110,12 @@ class MysqlUtils:
|
|
class CkUtils:
|
|
class CkUtils:
|
|
|
|
|
|
def __init__(self):
|
|
def __init__(self):
|
|
- self.client = Client(host='cc-bp1h3yc7o3g3o7k64o.ads.aliyuncs.com',
|
|
|
|
- user='qucheng_ck',
|
|
|
|
- password='Qc123456',
|
|
|
|
- port='3306',
|
|
|
|
|
|
+ self.config=db_config()
|
|
|
|
+ conf = self.config['clickhouse']
|
|
|
|
+ self.client = Client(host=conf['host'],
|
|
|
|
+ user=conf['user'],
|
|
|
|
+ password=conf['passwd'],
|
|
|
|
+ port=conf['port'],
|
|
send_receive_timeout=5)
|
|
send_receive_timeout=5)
|
|
|
|
|
|
def execute(self, sql):
|
|
def execute(self, sql):
|