How to safely maintain a status file

Duncan Booth duncan.booth at invalid.invalid
Mon Jul 9 16:02:54 CEST 2012

Richard Baron Penman <richardbp at> 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 

Duncan Booth

More information about the Python-list mailing list