@dexering

Почему возникает ошибка внесения в базу данных?

Код:
Код
import pymysql

conn = pymysql.connect(host=host, port=port, user=user, passwd=password, db=mydb)
cursor = conn.cursor()

us = str(input('username: '))
pd = str(input('password: '))
em = str(input('email: '))
jd = str(input('join date: '))


cursor.execute('''INSERT OR IGNORE INTO users (username, password, email, join_date) 
                   VALUES (%s, %s, %s, %s)''',
                   ( str(us),
                     str(pd),
                     str(em),
                     str(jd),
                   )
               )


conn.commit()
cursor.close()
conn.close()


Ошибка:

Ошибка
pymysql.err.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 'OR IGNORE INTO users (username, password, email, join_date) \n                   ' at line 1")


Помогите пожалуйста, уже второй день мучаюсь
  • Вопрос задан
  • 54 просмотра
Решения вопроса 1
lxstvayne
@lxstvayne
Люблю Python
Возможно это поможет:
cursor.execute('''INSERT OR IGNORE INTO users (username, password, email, join_date) VALUES (%s, %s, %s, %s)''',
                   ( str(us),
                     str(pd),
                     str(em),
                     str(jd),
                   )
               )
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы