Creating a Database
To create a database in MySQL, use the “CREATE DATABASE” statement:
Example
create a database named “mydatabase”:
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="yourusername",
password="yourpassword"
)
mycursor = mydb.cursor()
mycursor.execute("CREATE DATABASE mydatabase")
If the above code was executed with no errors, you have successfully created a database. Continue reading Python MySQL Create Database