Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

MySQL create database 1064 (42000) problem

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!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading