rlgallery-misc/py/cleandb.py
John "Elwin" Edwards aef04a38e1 Port to Python 3.
All scripts and modules have been ported to Python 3 and appear to
work.  Some changes to the lighttpd configuration were needed.
2013-12-31 13:36:19 -05:00

20 lines
409 B
Python
Executable file

#!/usr/bin/python3
# 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()