Answer the question
In order to leave comments, you need to log in
Why am I getting sqlite3.OperationalError: near "any word": syntax error?
Here is the function:
def write_comment(message):
conn = sqlite3.connect("m.db")
cursorObj = conn.cursor()
cursorObj.execute(
f'SELECT comment_text FROM settings WHERE id = {message.chat.id}')
rows = cursorObj.fetchall()
if len(rows) == 0:
cursorObj.execute(
'INSERT INTO settings(id,comment_text) VALUES(?,?)', (message.chat.id, message.text))
conn.commit()
cursorObj.execute(
f'UPDATE settings SET comment_text = {message.text} WHERE id = {message.chat.id}')
conn.commit()
bot.send_message(
message.chat.id, "✔️ Значение записано")
cursorObj.execute(
"CREATE TABLE IF NOT EXISTS settings(comment_text text, post_text text, wall_user_id integer, id integer)")
File "run_server.py", line 136, in write_comment
f'UPDATE settings SET comment_text = {message.text} WHERE id = {message.chat.id}')
sqlite3.OperationalError: no such column: tertert
Answer the question
In order to leave comments, you need to log in
Because you should not use string interpolation to form SQL queries.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question