I have a database containing a list of status updates and time stamp.
by executing the following python script
import sqlite3 as lite
import sys
con = lite.connect('Status.db')
with con:
cur = con.cursor()
cur.execute("SELECT * FROM Status")
print "The Status database now contains:"
for row in cur:
print row
results in the output:
The Status database now contains:
(1333155451.8815, u'message')
(1333155469.205055, u'message1')
(1333155473.496727, u'message2')
However, as the database grows, i wish to only view the latest, say, 10 messages. With the option of viewing older messages.
Could anyone give me some tips on how i would go about doing that?
Thanks
You can use
ORDER BYandLIMIT, aod use theDESCkeyword to show in reverse timestamp order:(For future reference: When you’re asking about how to query your data, you should post information about your schema, like table names, column names, and datatypes. It makes it much easier to post an answer containing the actual query.)