Here is the thing: I'm trying to make a new MySQL database by importing the name for the database and then creating it.
Here is the code:
import mysql.connector as mcon
# DB Connect
stdb = mcon.connect(
host = "localhost",
user = "root",
password = "pass",
database = "trffc_int_data")
cursor = stdb.cursor()
# Creating new DB
NewDB = input(" Enter the Database name : ")
sqlsynt = "CREATE DATABASE IF NOT EXISTS %s"
cursor.execute(sqlsynt,NewDB)
cursor.commit()
print ("New database created!")
Looks right, but I keep getting error "1065 >> 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 '%s'<<"
It points the line: cursor.execute(sqlsynt,NewDB)
What could be the problem?