How to disable query cache with mysql.connector

拥有回忆 提交于 2019-11-27 15:11:07

I solved this with adding the code after fetchall()

con.commit()

Calling the same select query without doing a commit, won't update the results.

The solution is to use:

  • Once:

    con.autocommit(True)
    
  • Or, after each select query:

    con.commit()
    

With this option, there will be a commit after each select query. Otherwise, subsequent selects will render the same result.

This error seems to be Bug #42197 related to Query cache and auto-commit in MySQL. The status is won't fix!

In a few months, this should be irrelevant because MySQL 8.0 is dropping Query Cache.

I encounterd the same problem that has been solved and used the above method.

conn.commit()

and I found that different DBMS has different behavior,not all DBMS exist in the connection cache

The MySQL query cache is flushed when tables are modified, so it wouldn't have that effect. It's impossible to say without seeing the rest of your code, but it's most likely that your INSERT / DELETE query is failing to run.

binbincai

try this,

conn.autocommit(True);

this will auto commit after each of you select query.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!