Exemplo n.º 1
0
 def tearDown(self) -> None:
     with self.conn.cursor() as cursor:
         clear_tables(cursor)
         drop_tables(cursor)
     self.conn.commit()
     self.conn.close()
Exemplo n.º 2
0
import psycopg2

from relational_database.config import DATABASE
from relational_database.db_utils import clear_tables, drop_tables

if __name__ == "__main__":
    con = psycopg2.connect(**DATABASE)
    with con.cursor() as cursor:
        try:
            clear_tables(cursor)
            drop_tables(cursor)
            con.commit()
        finally:
            if con:
                con.close()