Запускаю код:
import help_module as hm
import sqlite3
import time
connection = sqlite3.connect('Путь', check_same_thread = False)
cursor = connection.cursor()
while True:
for i in range(999999):
timer_status = hm.give_user_information2(i, 'timer', 'users')
if timer_status == 1:
neded_time = hm.give_user_information2(i, 'nt', 'users')
time = hm.give_user_information2(i, 'time', 'users')
if neded_time <= time:
vk.messages.send(
message=hm.give_user_information2(i, 'timer_text', 'users'),
peer_id=hm.give_user_information2(i, 'id', 'users'),
random_id=get_random_id()
)
cursor.execute("UPDATE users SET timer = 0 WHERE uid = " + str(i))
connection.commit()
cursor.execute("UPDATE users SET time = "+str(time.time())+" WHERE uid = " + str(i))
Ошибка:
Traceback (most recent call last):
File "Путь", line 17, in <module>
timer_status = hm.give_user_information2(i, 'timer', 'users')
File "Путь\help_module.py", line 11, in give_user_information2
return str(cursor.execute("SELECT " + info + " FROM " + table + " WHERE uid = " + str(id)).fetchone()[0])
TypeError: 'NoneType' object is not subscriptable
Часть модуля где возникает ошибка:
def give_user_information2(id, info, table):
connection = sqlite3.connect('Путь')
cursor = connection.cursor()
return str(cursor.execute("SELECT " + info + " FROM " + table + " WHERE uid = " + str(id)).fetchone()[0])
Отредактировано:
Если вывести neded_time, выводит 0:
timer_status = hm.give_user_information2(i, 'timer', 'users')
print(timer_status)
0
Traceback (most recent call last):
File "Путь", line 17, in <module>
timer_status = hm.give_user_information2(i, 'timer', 'users')
File "Путь\help_module.py", line 11, in give_user_information2
return str(cursor.execute("SELECT " + info + " FROM " + table + " WHERE uid = " + str(id)).fetchone()[0])
TypeError: 'NoneType' object is not subscriptable