init
This commit is contained in:
42
hts/HTS.py
42
hts/HTS.py
@@ -456,7 +456,7 @@ class HTS:
|
||||
|
||||
return data
|
||||
|
||||
def insertStockData(self, db_filename, stock_code, stock_name, today):
|
||||
def insertStockData(self, db_filename, today, stocks):
|
||||
tableName = 'hts'
|
||||
conn = sqlite3.connect(db_filename)
|
||||
cursor = conn.cursor()
|
||||
@@ -472,29 +472,31 @@ class HTS:
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
items = self.getStockInfo(stock_code, today)
|
||||
for stock in stocks:
|
||||
items = self.getStockInfo(stock["stock_code"], today)
|
||||
|
||||
conn = sqlite3.connect(db_filename)
|
||||
cursor = conn.cursor()
|
||||
idx = 0
|
||||
for item in items:
|
||||
ymd = item[0]
|
||||
hms = item[1]
|
||||
open = item[2]
|
||||
high = item[3]
|
||||
low = item[4]
|
||||
close = item[5]
|
||||
volume = item[6]
|
||||
conn = sqlite3.connect(db_filename)
|
||||
cursor = conn.cursor()
|
||||
idx = 0
|
||||
for item in items:
|
||||
ymd = item[0]
|
||||
hms = item[1]
|
||||
open = item[2]
|
||||
high = item[3]
|
||||
low = item[4]
|
||||
close = item[5]
|
||||
volume = item[6]
|
||||
|
||||
idx += 1
|
||||
idx += 1
|
||||
|
||||
cursor.execute('DELETE FROM ' + tableName + ' WHERE CODE=? and ymd=? and hms=?', (stock_code, ymd, hms,))
|
||||
cursor.execute("INSERT INTO " + tableName + "(CODE, NAME, ymd, hms, close, open, high, low, volume) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)", (stock_code, stock_name, ymd, hms, close, open, high, low, volume))
|
||||
cursor.execute('DELETE FROM ' + tableName + ' WHERE CODE=? and ymd=? and hms=?', (stock["stock_code"], ymd, hms,))
|
||||
cursor.execute("INSERT INTO " + tableName + "(CODE, NAME, ymd, hms, close, open, high, low, volume) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)", (stock["stock_code"], stock["stock_name"], ymd, hms, close, open, high, low, volume))
|
||||
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
print("insert...", stock_code, stock_name, today)
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
print("insert...", stock["stock_code"], stock["stock_name"], today)
|
||||
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user