[Collab-qa-commits] r858 - udd/src
neronus-guest at alioth.debian.org
neronus-guest at alioth.debian.org
Wed May 28 11:53:31 UTC 2008
Author: neronus-guest
Date: 2008-05-28 11:53:29 +0000 (Wed, 28 May 2008)
New Revision: 858
Added:
udd/src/delete-tables.py
Modified:
udd/src/aux.py
Log:
Added some comment to aux.py
Added script to delete all tables
Modified: udd/src/aux.py
===================================================================
--- udd/src/aux.py 2008-05-24 12:02:33 UTC (rev 857)
+++ udd/src/aux.py 2008-05-28 11:53:29 UTC (rev 858)
@@ -3,7 +3,7 @@
import syck
import sys
-# If debug is something that evaluates to True, then print_debug actually prints something :)
+# If debug is something that evaluates to True, then print_debug actually prints something
debug = 0
def get_archs(conn):
@@ -37,7 +37,9 @@
return "ConfigException: " + self.message
def load_config(seq):
- """Load and check configuration from seq"""
+ """Load and check configuration from seq.
+
+ seq has to be a sequence type, containings strings (see syck.load)"""
config = syck.load(seq)
if not 'dbname' in config:
raise ConfigException('dbname not specified')
Added: udd/src/delete-tables.py
===================================================================
--- udd/src/delete-tables.py (rev 0)
+++ udd/src/delete-tables.py 2008-05-28 11:53:29 UTC (rev 858)
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+import aux
+import psycopg2
+import sys
+
+def main():
+ if len(sys.argv) != 2:
+ print "Usage: %s <config>" % sys,argv[0]
+ sys.exit(1)
+
+ config = aux.load_config(sys.argv[1])
+
+ conn = psycopg2.connect(config['dbname'])
+
+ c = conn.cursor()
+ for table in ('sources', 'pkgs', 'distr_ids', 'arch_ids'):
+ c.execute("DELETE * FROM " + table)
+
+ conn.commit()
+ conn.close()
+
+if __name__ == '__main__':
+ main()
More information about the Collab-qa-commits
mailing list