Abhay Nayak
Abhay Nayak

Reputation: 1109

reading data only once in SQLite3 with Python

I've a sqlite3 database in python which increments every second as new data arrives from sensors. I need to read the latest value only

However if there's 50 entries which I've already read once, with a new entry, I have to read all 50 items again before the 51st item

I want to avoid reading through the same data over and over so I've added a "ReadStatusFlag" column which will be 1 if unread and flagged to 0 once read to avoid. Primary key is TimeStamp.

Is there any better way? just want to explore various approaches.

Upvotes: 0

Views: 128

Answers (1)

MultiSkill
MultiSkill

Reputation: 416

Select * from DataLog ORDER BY TimeStamp DESC LIMIT 1;

Adjust for your framework.

Upvotes: 4

Related Questions