0

I run the following Python script and receive the following error message:

mysql_exceptions.ProgrammingError: (1064, "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 'check' at line 1")

When I changed the database from check to check1 it the script works and also I didn't have earlier defined "check" database.

import MySQLdb as db
db1 = db.connect(host="localhost",user="root",passwd="vision@123")
cursor = db1.cursor()
sql = "CREATE DATABASE check;"
cursor.execute(sql)
db1.close()
0

2 Answers 2

1

check is a reserved word.

https://dev.mysql.com/doc/refman/5.5/en/keywords.html

The also will fail:

Create database select;
Sign up to request clarification or add additional context in comments.

Comments

1

Check is a reserved word in MySQL: http://dev.mysql.com/doc/refman/5.7/en/keywords.html and hence the error with "check" and not "check1".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.