Mercurial > hg > rlgallery-misc
annotate py/cleandb.py @ 5:a583700c0ca4
web/archive.cgi: fix backward comparisons.
Some form-printing code was using != instead of ==, which led to the
date defaulting to today whenever it was specified.
author | John "Elwin" Edwards <elwin@sdf.org> |
---|---|
date | Sun, 19 Aug 2012 15:26:18 -0700 |
parents | 5ba2123d2c20 |
children | e8f3b7994d88 |
rev | line source |
---|---|
0
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
2 # cleandb.py: empty the database in an orderly fashion |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
3 |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
4 import rlgalldb as rlgall |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
5 import psycopg2 |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
6 |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
7 dbconn = psycopg2.connect("dbname=rlg") |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
8 dbcur = dbconn.cursor() |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
9 |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
10 dbcur.execute("UPDATE games SET offbytes = %s", [0]) |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
11 |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
12 for game in rlgall.gamelist: |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
13 dbcur.execute("DELETE FROM " + game.uname + ";") |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
14 |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
15 dbcur.execute("DELETE FROM players;") |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
16 dbconn.commit() |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
17 |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
18 dbcur.close() |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
19 dbconn.close() |
5ba2123d2c20
Put this project under version control, finally.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff
changeset
|
20 exit() |