The way to Drop a MySQL Desk in Python


First, you have to the mysql.connector. In case you are uncertain of tips on how to get this setup, discuss with The way to Set up MySQL Driver in Python.

The way to Delete/Drop a MySQL Desk in Python

import mysql.connector

mydb = mysql.connector.join(
  host = "localhost",
  consumer = "username",
  password = "YoUrPaSsWoRd",
  database = "your_database"
)

mycursor = mydb.cursor()
sql = "DROP TABLE clients"
mycursor.execute(sql)

The way to Delete/Drop Provided that MySQL Desk Exists in Python

import mysql.connector

mydb = mysql.connector.join(
  host = "localhost",
  consumer = "username",
  password = "YoUrPaSsWoRd",
  database = "your_database"
)

mycursor = mydb.cursor()
sql = "DROP TABLE IF EXISTS clients"
mycursor.execute(sql)

Leave a Reply