import sqlite3
connect = sqlite3.connect("lun_db.db")
cursor = connect.cursor()
cursor.execute("""CREATE TABLE IF NOT EXISTS lun_db(
user_id INTEGER,
ochki INTEGER,
user_name TEXT
)
""")
connect.commit()
userid = 111
username = "ppppp"
cursor.execute(f"SELECT user_id FROM lun_db WHERE user_id = '{userid}'")
if cursor.fetchone() is None:
cursor.execute("INSERT INTO lun_db VALUES(?, ?, ?);", (userid, username ,0))
connect.commit()
cursor.execute(f'UPDATE lun_db SET user_name = {username} WHERE user_id = "{userid}"')
connect.commit()
File "C:\lun_bot\test_ckay_aiogram.py", line 157, in echo_message
cursor.execute(f'UPDATE lun_db SET user_name = {username} WHERE user_id = "{userid}"')
sqlite3.OperationalError: no such column: star
cursor.execute(f"SELECT user_id FROM lun_db WHERE user_id = '{userid}'")
if cursor.fetchone() is None:
cursor.execute("INSERT INTO lun_db VALUES(?, ?, ?);", (userid, 0, f"{username}"))
connect.commit()
cursor.execute('UPDATE lun_db SET user_name = ? WHERE user_id = ?', (f"{username}", userid))
Столбец user_name есть, но не работает
cursor.execute('UPDATE lun_db SET user_name = ? WHERE user_id = ?', (username, userid))