Stack Overflow на русском Asked by 0x04D8E470 on November 10, 2021
суть ошибки в том, что я не могу внести время в столбец SQL. Вот код:
def digger(user_id, current_time, digger_salary_time):
try:
digger_salary_time = check_time_digger(user_id)['digger_time']
print(f"Значение: {digger_salary_time}, тип: {type(digger_salary_time)}")
current_time = datetime.datetime.now().replace()
except Exception as e:
print(f"Опа! Произошла ошиба в использовании команды /копать! {e}")
if digger_salary_time == current_time:
return True
else:
time_getting_ore = int(time.time() + 30)
gg = datetime.datetime.fromtimestamp(time_getting_ore)
try:
res = next_salary_digger(user_id, gg)
except Exception as e:
print(f"Опа! Произошла ошибка в использовании команды /копать! {e}")
else:
return False
Вот запросы SQL
def next_salary_digger(user_id):
time_getting_ore = int(time.time() + 30)
gg = datetime.datetime.fromtimestamp(time_getting_ore)
print(gg)
connection = connect()
try:
with connection.cursor() as cursor:
result = cursor.execute(f"update untitled set `digger_time` = {gg} where uid = {user_id}")
row = cursor.fetchone()
return row
finally:
connection.close()
def check_time_digger(user_id):
connection = connect()
try:
with connection.cursor() as cursor:
result = cursor.execute(f"SELECT digger_time FROM untitled WHERE uid={user_id}")
row = cursor.fetchone()
if result == 1:
return row
finally:
connection.close()
Вот сама команда
elif event.text.lower() == "копать":
message = "⛏ Вы отправились в шахту за ценными ресурсами. nn ? Подождите 30 секунд, чтобы получить заработную плату."
writemsg(message)
user_id = event.user_id
next_salary_digger(user_id)
current_time = datetime.strftime(datetime.now(), '%H.%M.%S')
digger_salary_time = check_time_digger(user_id)['digger_time']
digger(user_id, current_time, digger_salary_time)
result_digger = digger(user_id, current_time, digger_salary_time)
if result_digger is True:
message = "Время закончилось"
writemsg(message)
else:
message = "Время не закончилось, жди"
writemsg(message)
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP