Python MySQL Drop Table

Delete a Table

You can delete an existing table by using the “DROP TABLE” statement:

Example

Delete the table “customers”:

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  password="yourpassword",
  database="mydatabase"
)

mycursor = mydb.cursor()

sql = "DROP TABLE customers"

mycursor.execute(sql)

Continue reading Python MySQL Drop Table