-
Notifications
You must be signed in to change notification settings - Fork 561
/
ImportZhBond10Task.py
48 lines (41 loc) · 1.58 KB
/
ImportZhBond10Task.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
# -*- coding: utf8 -*-
#
# Create on: 20240105
# Author: fasiondog
import sqlite3
import mysql.connector
from hikyuu.data.zh_bond10_to_mysql import import_zh_bond10_to_mysql
from hikyuu.data.zh_bond10_to_sqlite import import_zh_bond10_to_sqlite
from hikyuu.util import *
class ImportZhBond10Task:
def __init__(self, log_queue, queue, config):
self.log_queue = log_queue
self.queue = queue
self.config = config
self.task_name = 'IMPORT_ZH_BOND10'
self.status = "no run"
@hku_catch(trace=True)
def __call__(self):
self.status = "running"
capture_multiprocess_all_logger(self.log_queue)
if self.config.getboolean('hdf5', 'enable', fallback=True):
sqlite_file = "{}/stock.db".format(self.config['hdf5']['dir'])
connect = sqlite3.connect(sqlite_file, timeout=1800)
import_zh_bond10 = import_zh_bond10_to_sqlite
else:
db_config = {
'user': self.config['mysql']['usr'],
'password': self.config['mysql']['pwd'],
'host': self.config['mysql']['host'],
'port': self.config['mysql']['port']
}
connect = mysql.connector.connect(**db_config)
import_zh_bond10 = import_zh_bond10_to_mysql
try:
import_zh_bond10(connect)
except Exception as e:
hku_error(str(e))
connect.close()
self.queue.put([self.task_name, "ZH_BOND10", "10年期中国国债收益率下载完毕", None, None])
self.status = "finished"