Commit da739b0b authored by 子恒's avatar 子恒

[Bugfix]修复数据库实例问题。

parent 113e2fcd
...@@ -18,6 +18,9 @@ class BaseSync(object): ...@@ -18,6 +18,9 @@ class BaseSync(object):
source_db = '''mysql+mysqlconnector://{0}:{1}@{2}:{3}/{4}'''.format(config.hb_db_user, config.hb_db_pwd, source_db = '''mysql+mysqlconnector://{0}:{1}@{2}:{3}/{4}'''.format(config.hb_db_user, config.hb_db_pwd,
config.hb_db_host, config.hb_db_port, config.hb_db_host, config.hb_db_port,
config.hb_db_database) config.hb_db_database)
vision_db = '''mysql+mysqlconnector://{0}:{1}@{2}:{3}/{4}'''.format(config.vision_db_user, config.vision_db_pwd,
config.vision_db_host, config.vision_db_port,
config.vision_db_database)
destination_db = '''mysql+mysqlconnector://{0}:{1}@{2}:{3}/{4}'''.format(config.rl_db_user, destination_db = '''mysql+mysqlconnector://{0}:{1}@{2}:{3}/{4}'''.format(config.rl_db_user,
config.rl_db_pwd, config.rl_db_pwd,
config.rl_db_host, config.rl_db_host,
...@@ -25,6 +28,7 @@ class BaseSync(object): ...@@ -25,6 +28,7 @@ class BaseSync(object):
config.rl_db_database) config.rl_db_database)
# 源数据库 # 源数据库
self.source = sa.create_engine(source_db) self.source = sa.create_engine(source_db)
self.vision = sa.create_engine(vision_db)
# 目标数据库 # 目标数据库
self.destination = sa.create_engine(destination_db) self.destination = sa.create_engine(destination_db)
# 目标数据库Session # 目标数据库Session
...@@ -267,7 +271,7 @@ class BaseSync(object): ...@@ -267,7 +271,7 @@ class BaseSync(object):
def get_fd_secode(self, keep='all'): def get_fd_secode(self, keep='all'):
sql = f'select security_code,fsymbol,end_date as _end_date from fd_basic_info where flag=1' sql = f'select security_code,fsymbol,end_date as _end_date from fd_basic_info where flag=1'
result = pd.read_sql(sql, self.destination) result = pd.read_sql(sql, self.vision)
result['_end_date'] = result['_end_date'].replace(datetime.date(1900, 1, 1), datetime.date(2099, 1, 1)) result['_end_date'] = result['_end_date'].replace(datetime.date(1900, 1, 1), datetime.date(2099, 1, 1))
result = result.sort_values(['fsymbol', '_end_date']) result = result.sort_values(['fsymbol', '_end_date'])
index = result.drop_duplicates(subset=['fsymbol'], keep='last').index index = result.drop_duplicates(subset=['fsymbol'], keep='last').index
...@@ -280,5 +284,5 @@ class BaseSync(object): ...@@ -280,5 +284,5 @@ class BaseSync(object):
def get_manager_id(self, keep='all'): def get_manager_id(self, keep='all'):
sql = f'select distinct ps_code as manager_code,ps_name as manager_name,security_code from fd_manager_info where flag=1' sql = f'select distinct ps_code as manager_code,ps_name as manager_name,security_code from fd_manager_info where flag=1'
result = pd.read_sql(sql, self.destination) result = pd.read_sql(sql, self.vision)
return result return result
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment