35.1 Create Database
Creating a Database To create a database in MySQL, use the “CREATE DATABASE” statement: Example create a database named “mydatabase”:import mysql.connectormydb = mysql.connector.connect( host=”localhost”, user=”yourusername“, password=”yourpassword“)mycursor = mydb.cursor()mycursor.execute(“CREATE DATABASE mydatabase”)#If this page is executed with no error, you have successfully created a database. Output:C:\Users\My Name>python demo_mysql_create_db.py If the above code was executed with no errors, you have… Read More »