def getSzzs():
try:
data = ts.get_hist_data(code='000001', start='2016-01-01', end='2016-12-31')
# print (data)
number = '000001'
name = '????'
date = list(data.index) # ??
open = list(data.open) # ???
high = list(data.high) # ???
close = list(data.close) # ???
low = list(data.low) # ???
change = list(data.p_change) # ???
i = '000001_????_org'
cur1 = conn.cursor()
cur1.execute("DROP TABLE IF EXISTS %s;" % (i)) # ??????????
cur1.execute("""create table %s
(b_id int comment '??',
b_index varchar(100) comment '????',
b_name varchar(100) comment '????',
b_date date comment '??',
b_open float comment '???',
b_high float comment '???',
b_close float comment '???',
b_low float comment '???',
b_change float comment '???',
PRIMARY key(b_id));""" % (i))
for j in range(0, len(date)):
# print (j + 1, number, name, date[j], open[j], high[j], close[j], low[j], change[j])
cur1.execute("INSERT INTO %s(b_id, b_index, b_name, b_date, b_open, b_high, b_close, b_low, b_change) "
"VALUES('%d', '%s', '%s', '%s', '%f', '%f', '%f', '%f', '%f');"
% (i, j + 1, number, name, date[j], open[j], high[j], close[j], low[j], change[j]))
cur1.execute("commit;")
except Exception:
pass
评论列表
文章目录