| 1234567891011121314151617181920 |
- import database
- import stocks
- # Retrieve last and second to last timestamp from the server
- db = database.db
- cursor = db.cursor()
- query = """SELECT DISTINCT timestamp FROM stocks ORDER BY stocks.timestamp DESC LIMIT 1 OFFSET 1;"""
- cursor.execute(query)
- one_before_latest_entry_timestamp = cursor.fetchone()[0]
- query = """SELECT DISTINCT timestamp FROM stocks ORDER BY stocks.timestamp DESC LIMIT 1;"""
- cursor.execute(query)
- latest_entry_timestamp = cursor.fetchone()[0]
- print(one_before_latest_entry_timestamp)
- print(latest_entry_timestamp)
- cursor.close()
- db.close()
|