c = sqlite3.connect('const.sqlite')
myCursor = c.cursor()
myCursor.executescript('''CREATE TABLE IF NOT EXISTS User (user_id INTEGER, step);''')
myCursor.execute('SELECT COUNT(user_id = (?)) FROM User ;', [(user_id)])
a = myCursor.fetchone()
aa = a[0]
print(aa)
if aa < 1:
myCursor.execute("INSERT OR REPLACE INTO User (user_id) VALUES (?)", [(user_id)])
c.commit()
def set_state(user_id, value):
make(user_id)
c = sqlite3.connect('const.sqlite')
myCursor = c.cursor()
myCursor.execute("UPDATE User SET step = (?)WHERE user_id = (?);", [(value), (user_id)])
c.commit()
def get_current_state(user_id):
make(user_id)
c = sqlite3.connect('const.sqlite')
value = c.execute("SELECT step FROM User WHERE user_id = ?", (user_id,)).fetchall()
print(value)
value1 = value[0]
value2 = value1[0]
return value2
set_state(123458, "5")
print(get_current_state(123458))
value1 = value[0] IndexError: list index out of range
я понял, это работает но 1 раз
Обсуждают сегодня