Answer the question
In order to leave comments, you need to log in
Sqlite3.OperationalError: table stats has no column named user_id?
class SQLighter:
def __init__(self, database):
self.connection = sqlite3.connect(database, check_same_thread = False)
self.cursor = self.connection.cursor()
self.cursor.execute("CREATE TABLE IF NOT EXISTS stats (user_id INT, user_name TEXT, survived INT, infected INT)")
def add_user(self, id, name, survived, infected):
with self.connection:
return self.cursor.execute("""INSERT INTO `stats` (user_id, user_name, survived, infected) VALUES (?,?,?,?)""", (id, name, survived, infected))
def get_nick(self, id):
with self.connection:
return self.cursor.execute("SELECT user_id FROM stats WHERE id = ?", (id, )).fetchall()
def set_fast(self, id):
with self.connection:
return self.cursor.execute("UPDATE stats SET infected=X WHERE id=?", (id))
sql_lighter.get_nick(754651730)
sql_lighter.get_nick(982543922)
Answer the question
In order to leave comments, you need to log in
You are looking for an id column that you did not create. Questions?
def __init__(self, database):
self.connection = sqlite3.connect(database, check_same_thread = False)
self.cursor = self.connection.cursor()
self.cursor.execute("CREATE TABLE IF NOT EXISTS stats (user_id INT, user_name TEXT, survived INT, infected INT)")
self.connection.commit()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question