0

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.

1
  • If you are fetching the rows by SQL, articulating a query which fetches only the newest timestamp should be trivial. Are you having trouble phrasing this in SQL or did this obvious solution not occur to you? Commented Dec 22, 2017 at 7:13

1 Answer 1

4
Select * from DataLog ORDER BY TimeStamp DESC LIMIT 1;

Adjust for your framework.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.