Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25084
| From | Duncan Booth <duncan.booth@invalid.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: How to safely maintain a status file |
| Date | 2012-07-09 14:02 +0000 |
| Message-ID | <XnsA08B98A8ACFF1duncanbooth@127.0.0.1> (permalink) |
| References | <mailman.1916.1341747003.4697.python-list@python.org> |
Richard Baron Penman <richardbp@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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
How to safely maintain a status file Richard Baron Penman <richardbp@gmail.com> - 2012-07-08 21:29 +1000 Re: How to safely maintain a status file Duncan Booth <duncan.booth@invalid.invalid> - 2012-07-09 14:02 +0000
csiph-web