Выдаёт ошибку
"UnboundLocalError: local variable 'singup' referenced before assignment"
.
P.S я знаю что ошибся в слове "signup" но дело не в этом.
import sqlite3
class Database:
def __init__(self, db_file):
self.connection = sqlite3.connect(db_file)
self.cursor = self.connection.cursor()
def add_user(self, user_id):
with self.connection:
return self.cursor.execute("INSERT INTO 'users' ('user_id') VALUES (?)", (user_id,))
def user_exists(self, user_id):
with self.connection:
result = self.cursor.execute("SELECT * FROM 'users' WHERE 'user_id' = ?", (user_id,)).fetchall()
return bool(len(result))
def set_nikname(self, user_id, nickname):
with self.connection:
return self.cursor.execute("UPDATE 'users' SET 'nickname' = ? WHERE 'user_id' = ?", (nickname, user_id,))
def get_singup(self, user_id):
with self.connection:
result = self.cursor.execute("SELECT 'singup' FROM 'users' WHERE 'user_id' = ?", (user_id,)).fetchall()
for row in result:
singup = str(row[0])
return singup
def set_singup(self, user_id, singup):
with self.connection:
return self.cursor.execute("UPDATE 'users' SET 'singup' = ? WHERE 'user_id' = ?", (singup, user_id,))