How to create MySQL database if not exists with 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=""
)
 
db_cursor = db.cursor()

db_cursor.execute("CREATE DATABASE IF NOT EXISTS python_database")

 
'''
run:
 

'''

 



answered Nov 28, 2018 by avibootz

Related questions

1 answer 271 views
2 answers 422 views
1 answer 265 views
1 answer 224 views
224 views asked Nov 27, 2018 by avibootz
1 answer 328 views
1 answer 267 views
...