I'm trying to iterate through my data one row at a time, comparing the last row added to previous rows. Simulating a live scenario. I'm stuck as to how I can use OFFSET to go in the other direction. -91?
eg. LIMIT 91 OFFSET -91 (get row 91, then 98,97,96..0)
columns = ['AWE', 'MSB', 'LNG', 'BRG', 'FLT']
c1 = conn.cursor()
c2 = conn.cursor()
c1.execute("SELECT max(id) FROM prices")
total_rows = c1.fetchone()
def fetch_prices():
for i in range(len(columns)):
c2.execute("SELECT "'"%s"'" FROM prices LIMIT %s, 91" % (columns[i], current_row))
results_current = c2.fetchall()
for x in range(91, total_rows[0]):
print("*** ROW %s ***" % x)
current_row = x
fetch_prices()
Let me know if this is realistic, or if I just need to rethink it.
Aucun commentaire:
Enregistrer un commentaire