How to safely maintain a status file
Duncan Booth
duncan.booth at invalid.invalid
Mon Jul 9 10:02:54 EDT 2012
Richard Baron Penman <richardbp at gmail.com> wrote:
> Is there a better way? Or do I need to use a database?
Using a database would seem to meet a lot of your needs. Don't forget that
Python comes with a sqlite database engine included, so it shouldn't take
you more than a few lines of code to open the database once and then write
out your status every few seconds.
import sqlite3
con = sqlite3.connect('status.db')
...
with con:
cur = con.cursor()
cur.execute('UPDATE ...', ...)
and similar code to restore the status or create required tables on
startup.
--
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list
mailing list