Mercurial > hg > rlgallery-misc
diff py/cleandb.py @ 0:5ba2123d2c20
Put this project under version control, finally.
Scripts for rlgallery.org, using a PostgreSQL backend. The recorder
system is in py/, CGI scripts are in web/.
author | John "Elwin" Edwards <elwin@sdf.org> |
---|---|
date | Wed, 25 Jul 2012 21:59:42 -0700 |
parents | |
children | e8f3b7994d88 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/py/cleandb.py Wed Jul 25 21:59:42 2012 -0700 @@ -0,0 +1,20 @@ +#!/usr/bin/python +# cleandb.py: empty the database in an orderly fashion + +import rlgalldb as rlgall +import psycopg2 + +dbconn = psycopg2.connect("dbname=rlg") +dbcur = dbconn.cursor() + +dbcur.execute("UPDATE games SET offbytes = %s", [0]) + +for game in rlgall.gamelist: + dbcur.execute("DELETE FROM " + game.uname + ";") + +dbcur.execute("DELETE FROM players;") +dbconn.commit() + +dbcur.close() +dbconn.close() +exit()