How to delete MySQL database table only if exist in Python

1 Answer

0 votes
# c:\Users\user_nm\AppData\Local\Programs\Python\Python35-32\Scripts\pip install mysql-connector
    
import mysql.connector
    
db = mysql.connector.connect(
    host="localhost",
    user="root",
    passwd="",
    database="python_database"
)
   
db_cursor = db.cursor()

sql = "DROP TABLE IF EXISTS python_table"

db_cursor.execute(sql)

db.close()

 
'''
run:
  

'''

 



answered Dec 3, 2018 by avibootz
...