import mysql.connector
from mysql.connector import Error
from nbdev.showdoc import *
SQL Cleanup
Ensuring Tables Are Empty Before Running SQL Solution
try:
= mysql.connector.connect(user='root', host='localhost')
connection = connection.cursor()
cursor """
cursor.execute( USE exam_db;
DROP TABLE temp_contact_methods;
DROP TABLE temp_contacts;
DROP TABLE temp_gifts;
DROP TABLE contact_methods;
DROP TABLE contacts;
DROP TABLE gifts;
""")
except Error as e:
print(f"Error: {e}")
finally:
if connection.is_connected():
cursor.close() connection.close()