MySQL create database 1064 (42000) problem
Question:
Hi I have this problem when creating a new database table:
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 '' at line 1
import mysql.connector
db = mysql.connector.connect(
host="localhost",
user="root",
database="ims"
)
mycursor = db.cursor()
mycursor.execute("CREATE TABLE newitem (code VARCHAR(20), price FLOAT(10), color VARCHAR(50),
nis INT(100), nim INT(100), nil INT(100), nixl INT(100), nixxl INT(100), nif INT(100), nitotal
VARCHAR(100)")
I’ve also tried few solutions found online but its still not working. Can anyone help with this? Thank you very much!
Answers:
You need to close your CREATE
statement with another )
statement = """CREATE TABLE newitem(
code VARCHAR(20),
price FLOAT(10),
color VARCHAR(50),
nis INT(100),
nim INT(100),
nil INT(100),
nixl INT(100),
nixxl INT(100),
nif INT(100),
nitotal VARCHAR(100))""" # two )'s before ending the quote
mycursor.execute(statement)
Hi I have this problem when creating a new database table:
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 '' at line 1
import mysql.connector
db = mysql.connector.connect(
host="localhost",
user="root",
database="ims"
)
mycursor = db.cursor()
mycursor.execute("CREATE TABLE newitem (code VARCHAR(20), price FLOAT(10), color VARCHAR(50),
nis INT(100), nim INT(100), nil INT(100), nixl INT(100), nixxl INT(100), nif INT(100), nitotal
VARCHAR(100)")
I’ve also tried few solutions found online but its still not working. Can anyone help with this? Thank you very much!
You need to close your CREATE
statement with another )
statement = """CREATE TABLE newitem(
code VARCHAR(20),
price FLOAT(10),
color VARCHAR(50),
nis INT(100),
nim INT(100),
nil INT(100),
nixl INT(100),
nixxl INT(100),
nif INT(100),
nitotal VARCHAR(100))""" # two )'s before ending the quote
mycursor.execute(statement)