def getHistoricalSplit(tickerName): tempData = sql.executeReturn('SELECT * FROM ' + tickerName) data = [] for i in tempData: data.append([i[0], float(i[7])]) return data
def getAllTables(): allTables = sql.executeReturn("SELECT name FROM sqlite_master WHERE type = 'table';") tables = [] for i in allTables: print(i) for i in allTables: tables.append(i[0]) return tables
def getHistoricalPrices(tickerName): tempData = sql.executeReturn('SELECT * FROM ' + tickerName) data = [] for i in tempData: temp = [] for j in i: temp.append(j) data.append(temp) return data
def updateHistoricalPrice(tickerName): tableName = tickerName tempData = sql.executeReturn('SELECT * FROM ' + tableName) sqlData = [] for i in tempData: temp = [] for j in i: temp.append(j) sqlData.append(temp) newData = Download.updateHistoricalPrice(tickerName, sqlData) #@Unresolved # for i in newData: # print(i) insertMechanism(tickerName, newData)
def insertMechanism(tickerName, data): sql.execute('DROP TABLE IF EXISTS ' + tickerName, None) sql.execute('CREATE TABLE ' + tickerName + '(CC0 TEXT, CC1 TEXT, CC2 TEXT, CC3 TEXT, CC4 TEXT, CC5 TEXT, CC6 TEXT, CC7 TEXT)', None) totalText = '' for i in data: totalText += '(' for j in i: totalText += "'" + str(j) + "'," totalText = totalText[0:len(totalText) -1 ] totalText += '),' # tempArray.append(j) # totalText += valuesText + ',' totalText = totalText[0:len(totalText)-1] sql.execute('INSERT INTO ' + tickerName + ' VALUES ' + totalText , None)
def vacuum(): sql.execute("VACUUM", None)
def removeTicker(tickerName): sql.execute('DROP TABLE IF EXISTS ' + tickerName, None)
def getAll(): allTables = sql.executeReturn( "SELECT name FROM sqlite_master WHERE type = 'table';") return allTables