my_sql_code = 'DROP TABLE...'
statements = my_sql_code.split(';')
statements = [s for s in statements if 'tableB' in s]
for s in statements:
    execute_sql(s)
How can I parse sql file from within Python?