PyMySql: кэшируются запросы

Рейтинг: 0Ответов: 0Опубликовано: 26.01.2023

После некоторых циклов выполнения запросы просто кэшируются и не меняют ответ запроса, даже если менять информацию в бд.

КОД:

def find_pair():
    while True:
        cur.execute("select id, user_one, dialog_configuration from chats WHERE user_two = 0 and queue_time = 0")
        data = cur.fetchall()
        for i in data:
            id = i['id']
            user_one = i['user_one']
            dialog_configuration  = i['dialog_configuration']
            
            print(id, user_one, dialog_configuration)
            cur.execute("SELECT user_one FROM chats WHERE user_two = 0 and queue_time = 0 and dialog_configuration = %s and user_one != %s", (dialog_configuration, user_one))
            user_two = cur.fetchone()
            if user_two != None:
                cur.execute("""UPDATE chats SET user_two = %s WHERE id = %s""", (user_two['user_one'], id, ))
                con.commit()
        print("Working!")
        time.sleep(2)

Строение таблицы:

  • id

  • user_one - собеседник1

  • user_two - собеседник2

  • queue_time - место в очереди

  • dialog_configuration - конфигурация диалога

Ответы

Ответов пока нет.