view py/cleandb.py @ 74:900da50ee11c

Merge lighttpd configuration into one include file. The lighttpd configuration was previously spread across several files which were intended to overwrite the defaults. They often became outdated. Now all customization is in lighttpd/rlgallery.conf, which should be included at the end of whatever main lighttpd configuration file is in use. It should require minimal updates for new lighttpd versions or distribution changes.
author John "Elwin" Edwards
date Wed, 28 Dec 2016 13:12:04 -0500
parents 25843238434a
children
line wrap: on
line source

#!/usr/bin/python3
# cleandb.py: empty the database in an orderly fashion

import 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()