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-Python Wont create the table

I am trying to create a few tables using Python, the first few worked and this specific one not.
This is my code:

sql = "CREATE TABLE citizens(\
    ID INT PRIMARY KEY AUTO_INCREMENT,\
    full_name VARCHAR(100),\
    age INT,\
    Gender ENUM('F', 'M'),\
    cultivation VARCHAR(100),\
    rank INT,\
    isRouge ENUM('Yes', 'No'),\
    sect_id INT)"

mycursor.execute(sql)

and this is the error it gives me:

MySQLInterfaceError: 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 'rank INT,    isRouge ENUM('Yes', 'No'),    sect_id INT)' at line 1

what is it thaat I am missing?

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 :

"rank" bad field name. This is a reserved word
https://dev.mysql.com/doc/refman/8.0/en/keywords.html

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