Hi everyone,
I'm testing in memory SQLite DB to use with Flask
here my simple test
The f_insert2mem insert in the DB the current time.
then a SQL query fetch all the record in the same table
and flask should simply display the full list of items.
What's happening
When I visit the first time the page it work as expected I got in the browser
I refresh the page I got
and the third time I refresh I got
and when I continue to refresh I got randomly the records with only the first 1 or 2, 3 items. and sometimes all of them !?
Any ideas ?
Thanks
I'm testing in memory SQLite DB to use with Flask
here my simple test
Conn = sqlite3.connect(':memory:') ConnCursor = Conn.cursor() ConnCursor.execute('PRAGMA foreign_keys = ON;') ConnCursor.execute("\ CREATE TABLE IF NOT EXISTS Test (\ id INTEGER NOT NULL UNIQUE PRIMARY KEY,\ data TEXT NOT NULL)") def f_insert2mem(inject): ConnCursor.execute("\ INSERT INTO Test\ (data) VALUES\ (?)",[inject]) Conn.commit @app.route('/testmem') def road_testmem(): f_insert2mem(str(arrow.now())) ConnCursor.execute('SELECT * from Test') records = ConnCursor.fetchall() return str(records)So when you visit the endpoint localhost/testmem
The f_insert2mem insert in the DB the current time.
then a SQL query fetch all the record in the same table
and flask should simply display the full list of items.
What's happening
When I visit the first time the page it work as expected I got in the browser
Quote:[(1, '2023-01-18T05:35:48.497469+00:00')]
I refresh the page I got
Quote:[(1, '2023-01-18T05:35:48.497469+00:00'), (2, '2023-01-18T05:35:49.442227+00:00')]
and the third time I refresh I got
Quote:[(1, '2023-01-18T05:35:48.497469+00:00')]
and when I continue to refresh I got randomly the records with only the first 1 or 2, 3 items. and sometimes all of them !?
Any ideas ?
Thanks
![[Image: NfRQr9R.jpg]](https://i.imgur.com/NfRQr9R.jpg)