Deleting data stmt_delete_tr delete from public transactions_fh where

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Deleting data
stmt_delete_tr = """delete from public.transactions_fh where cre_date < date(sysdate - 7)"""
print(stmt_delete_tr)
logging.info(stmt_delete_tr)
logging.info("Deleting transactions table")
redshift_cursor.execute(stmt_delete_tr)
redshift_conn.commit()
stmt_delete_imp = """delete from public.impressions_fh where set_date < date(sysdate - 7)"""
print(stmt_delete_imp)
logging.info(stmt_delete_imp)
logging.info("Deleting impressions table")
redshift_cursor.execute(stmt_delete_imp)
redshift_conn.commit()
stmt_delete_click = """delete from public.clicks_fh where cre_date < date(sysdate - 30)"""
print(stmt_delete_click)
logging.info(stmt_delete_click)
logging.info("Deleting clicks table")
redshift_cursor.execute(stmt_delete_click)
redshift_conn.commit()
# Closing all connections
redshift_conn.close()
logging.info('Process delete_big_tables_process.py Finished Successfuly')