0

I have looked up so many things online and have tried literally everything. The db is on hostinger. Its mariadb and I've searched everything on it and nothing has worked or changed.

The error:

mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key)        
              VALUES ('a', 'b', 'c')' at line 2
import mysql.connector
conn = mysql.connector.connect(
    host = "myhost",
    user = "myuser",
    passwd = "mypass",
    database = "mydatabase"
)
mycursor = conn.cursor()

discord = input("gimme: ")
userid = input("gimme: ")
key = input("gimme: ")
sqlFormula = """INSERT INTO info 
              (discord, userid, key) 
              VALUES (%s, %s, %s)"""
yeet = (discord,userid,key)

mycursor.execute(sqlFormula, yeet)

conn.commit()
conn.close()
SOLVED:

KEY is a reserved keyword, you will have to quote the column name. In general try to prevent using names that are keywords. – Klaus D.
^^^^^^
This was the error, changed the column from KEY to KEIY and it worked
Aotric
  • 3
  • 2
  • 1
    `KEY` is a reserved keyword, you will have to quote the column name. In general try to prevent using names that are keywords. – Klaus D. May 08 '20 at 05:40
  • I truly love you, that worked and you my friend deserve a gold medal. – Aotric May 08 '20 at 06:23

0 Answers0