This is the error:
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
Here is the code that I use to create the database:
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd = "password12",
)
my_cursor = mydb.cursor()
my_cursor.execute("CREATE DATABASE database")
my_cursor.execute("SHOW DATABASES")
for db in my_cursor:
print(db)
I tried using a different name for the database, but I still got the same error.