2 Functions for removing unnecessary data from the database.
4 from pathlib import Path
6 from psycopg2 import sql as pysql
22 def drop_update_tables(conn):
23 """ Drop all tables only necessary for updating the database from
26 parts = (pysql.SQL("(tablename LIKE {})").format(pysql.Literal(t)) for t in UPDATE_TABLES)
28 with conn.cursor() as cur:
29 cur.execute(pysql.SQL("SELECT tablename FROM pg_tables WHERE ")
30 + pysql.SQL(' or ').join(parts))
31 tables = [r[0] for r in cur]
34 cur.drop_table(table, cascade=True)
39 def drop_flatnode_file(fname):
40 """ Remove the flatnode file if it exists.