import mysql.connector
# Establishing connection to the database
mydb = mysql.connector.connect(
host="localhost",
user="yourusername",
password="yourpassword",
database="yourdatabase"
)
# Creating a cursor object
mycursor = mydb.cursor()
# SQL statement to drop table if exists
sql = "DROP TABLE IF EXISTS yourtable"
# Executing the SQL command
mycursor.execute(sql)
# Commit the changes to the database
mydb.commit()
# Closing the database connection
mydb.close()
print("Table deleted successfully!")