Mercurial > hg > rlgallery-misc
comparison 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 | 
   comparison
  equal
  deleted
  inserted
  replaced
| -1:000000000000 | 0:5ba2123d2c20 | 
|---|---|
| 1 #!/usr/bin/python | |
| 2 # cleandb.py: empty the database in an orderly fashion | |
| 3 | |
| 4 import rlgalldb as rlgall | |
| 5 import psycopg2 | |
| 6 | |
| 7 dbconn = psycopg2.connect("dbname=rlg") | |
| 8 dbcur = dbconn.cursor() | |
| 9 | |
| 10 dbcur.execute("UPDATE games SET offbytes = %s", [0]) | |
| 11 | |
| 12 for game in rlgall.gamelist: | |
| 13 dbcur.execute("DELETE FROM " + game.uname + ";") | |
| 14 | |
| 15 dbcur.execute("DELETE FROM players;") | |
| 16 dbconn.commit() | |
| 17 | |
| 18 dbcur.close() | |
| 19 dbconn.close() | |
| 20 exit() | 
