Запускаю данную функцию через threading, выводит ошибку:
minesmscid = qwe.fetchone()[0]
sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 11276 and this is thread id 1124.
def func():
with sqlite3.connect('country.db', check_same_thread = False,timeout=10,detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES) as con:
cur = con.cursor()
while True:
cur.execute(''' SELECT mine_country_owner, mine_country_planet_id, mine_search FROM mine_table WHERE mine_search != 0''')
dt = cur.fetchall()
now = datetime.datetime.now()
for i in dt:
if "-" not in str(now - i[2]):
uses_left = random.randint(15,30)
cur.execute(''' UPDATE mine_table SET mine_search = 0 WHERE mine_country_owner = ? AND mine_country_planet_id = ? ''', [i[0], i[1]])
cur.execute(''' UPDATE mine_table SET mine_uses_left = ? WHERE mine_country_owner = ? AND mine_country_planet_id = ? ''', [uses_left, i[0], i[1]])
cur.execute(''' UPDATE mine_table SET mine_status = 2 WHERE mine_country_owner = ? AND mine_country_planet_id = ? ''', [i[0], i[1]])
cur.execute(''' SELECT planet_chat_id FROM planet_table WHERE planet_id = ? ''', [i[1]])
minesmscid = qwe.fetchone()[0]