Friday, March 17, 2023
HomeSoftware EngineeringThe right way to Drop a MySQL Desk in Python

The right way to Drop a MySQL Desk in Python


First, you’ll need the mysql.connector. In case you are not sure of how you can get this setup, consult with The right way to Set up MySQL Driver in Python.

The right way to Delete/Drop a MySQL Desk in Python

import mysql.connector

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

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

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

import mysql.connector

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

mycursor = mydb.cursor()
sql = "DROP TABLE IF EXISTS prospects"
mycursor.execute(sql)
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments