Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
hb-data
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
子恒
hb-data
Commits
da739b0b
Commit
da739b0b
authored
Dec 22, 2021
by
子恒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix]修复数据库实例问题。
parent
113e2fcd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
base_sync.py
sync/base_sync.py
+6
-2
No files found.
sync/base_sync.py
View file @
da739b0b
...
...
@@ -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
,
config
.
hb_db_host
,
config
.
hb_db_port
,
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
,
config
.
rl_db_pwd
,
config
.
rl_db_host
,
...
...
@@ -25,6 +28,7 @@ class BaseSync(object):
config
.
rl_db_database
)
# 源数据库
self
.
source
=
sa
.
create_engine
(
source_db
)
self
.
vision
=
sa
.
create_engine
(
vision_db
)
# 目标数据库
self
.
destination
=
sa
.
create_engine
(
destination_db
)
# 目标数据库Session
...
...
@@ -267,7 +271,7 @@ class BaseSync(object):
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'
result
=
pd
.
read_sql
(
sql
,
self
.
destinat
ion
)
result
=
pd
.
read_sql
(
sql
,
self
.
vis
ion
)
result
[
'_end_date'
]
=
result
[
'_end_date'
]
.
replace
(
datetime
.
date
(
1900
,
1
,
1
),
datetime
.
date
(
2099
,
1
,
1
))
result
=
result
.
sort_values
([
'fsymbol'
,
'_end_date'
])
index
=
result
.
drop_duplicates
(
subset
=
[
'fsymbol'
],
keep
=
'last'
)
.
index
...
...
@@ -280,5 +284,5 @@ class BaseSync(object):
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'
result
=
pd
.
read_sql
(
sql
,
self
.
destinat
ion
)
result
=
pd
.
read_sql
(
sql
,
self
.
vis
ion
)
return
result
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment