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)")
self.connection.commit()
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 user_id = ?", (id, )).fetchall()
def set_fast(self, id, survived, infected):
with self.connection:
return self.cursor.execute("UPDATE stats SET infected = ?, survived = ? WHERE user_id=?", (infected, survived, id))
def get_infected_and_survived(self, id):
return self.cursor.execute(f'SELECT infected, survived FROM stats WHERE user_id={id}')
sql_lighter = SQLighter("database.db")
sql_lighter.add_user(982543922, "Вова", 1, 1)
sql_lighter.add_user(754651730, "Андрей", 2, 2)
sql_lighter.get_infected_and_survived(754651730)
sql_lighter.get_infected_and_survived(982543922)
infected = 0
survived = 0
infected = 0
survived = 0
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)")
self.connection.commit()
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:
self.cursor.execute("SELECT user_id FROM stats WHERE user_id = ?", (id, )).fetchall()
self.connection.commit()
def set_fast(self, id, survived, infected):
with self.connection:
self.cursor.execute("UPDATE stats SET infected = ?, survived = ? WHERE user_id = ?", (infected, survived, id))
self.connection.commit()
sql_lighter = SQLighter("database.db")
sql_lighter.add_user(982543922, "Вова", 1, 1)
sql_lighter.add_user(754651730, "Андрей", 2, 2)
sql_lighter.set_fast(982543922, 1, 1)
sql_lighter.set_fast(754651730, 2, 2)
sql_lighter.get_nick(754651730)
sql_lighter.get_nick(982543922)
if message.text.lower() == ' мой профиль':
bot.send_message(message.chat.id, f"Мой профиль\nМой ID: [{message.from_user.id}]\nМой Псевдоним: [{message.from_user.username}]\nМоё Ф.И: [{message.from_user.first_name} {message.from_user.last_name}]\nКоличество побед за выжившего: [{survived}]\nКоличество заражений за заражённого: [{infected}]\nВерсия помощника бота: [V0.3]\nВерсия игры зомби: [V0.9]")
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)")
self.connection.commit()
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:
self.cursor.execute("SELECT user_id FROM stats WHERE user_id = ?", (id, )).fetchall()
self.connection.commit()
def set_fast(self, id, survived, infected):
with self.connection:
self.cursor.execute("UPDATE stats SET infected = ?, survived = ? WHERE user_id = ?", (infected, survived, id))
self.connection.commit()
sql_lighter = SQLighter("database.db")
sql_lighter.add_user(982543922, "Вова", 1, 1)
sql_lighter.add_user(754651730, "Андрей", 2, 2)
sql_lighter.set_fast(982543922, 1, 1)
sql_lighter.set_fast(754651730, 2, 2)
sql_lighter.get_nick(754651730)
sql_lighter.get_nick(982543922)