1 """
2 This module contains function to clean tables from PostgreSQL.
3 """
4
5 from multiprocessing import Pool
6 import time
7 import sys, getopt
8 import random
9
10 import sys_appends
11
12 import psycopg2
13
15 """
16 Cleans all tables in the database whose names are similar to the given parameter name
17 @type stem: string
18 @param stem: name of the table where similar names would be cleaned from the database
19 """
20 connect_str = 'dbname=' + sys_appends.dbname
21 conn = psycopg2.connect(connect_str)
22 psql = conn.cursor()
23 psql.execute("SELECT tablename from pg_tables where tablename LIKE '%s%%'" % (stem))
24 for (tname,) in psql.fetchall():
25 print "DROP TABLE %s;" % (tname)
26
27 clean_tables('staging_data')
28 clean_tables('epoch')
29 clean_tables('victor')
30