view py/cleandb.py @ 50:4549b3c0cd28

rlgall.py: add time selection to Game.getHigh(). Optional inittime and finaltime parameters set the range of time over which to calculate high scores.
author John "Elwin" Edwards
date Fri, 28 Mar 2014 09:33:49 -0700
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()