My database is written to every second during certain hours. It's also read from during same hours, every minute.
The read outputs different values during operational hours vs. after hours. Might be data is not written when I read. How to fix this or make sure data for last minute is complete before reading? Would a different database do better?
How I am reading:
conn = sqlite3.connect(f'{loc_tick}/tick.db',
detect_types=sqlite3.PARSE_DECLTYPES, timeout=20, isolation_level=None)
select_statement = f"select * from symfut WHERE
timestamp >= date('now', '-10 days')"
m1df = pd.read_sql(select_statement, conn)
Write:
conn = sqlite3.connect('tick.db',
detect_types=sqlite3.PARSE_DECLTYPES, timeout=20,isolation_level=None)
c = conn.cursor()
c.execute('PRAGMA journal_mode=wal')
c.execute('PRAGMA wal_autocheckpoint = 100')
c.execute('INSERT INTO symfut (timestamp, c, b, a) VALUES (?,?,?,?)',
(timestamp, c, b, a))
source https://stackoverflow.com/questions/74525915/select-during-vs-after-insert-produces-different-results
Comments
Post a Comment