推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
SystemLight
V2EX  ›  Python

tornado 中使用 tormysql 读取数据有时读到的数据是之前查询的数据?

  •  
  •   SystemLight ·
    SystemLight · Apr 26, 2020 · 2454 views
    This topic created in 2386 days ago, the information mentioned may be changed or developed.

    我在全局使用了一个 tormysql 的 pool 对象,每个请求都从中生成一个数据库连接对象 Connection,但是我发现有的时候请求会不是当前提交过的数据,如数据库里面已经更新了新数据,但是查询的仍然是之前的数据,而且这些出现的数据不固定,有时是正常的有时是之前查过的数据

    5 replies  •  2020-04-28 12:58:21 +08:00
    baocaixiong
    baocaixiong
    Apr 26, 2020
    1
    没 commit 吧
    hushao
    hushao
    Apr 26, 2020
    2
    描述的比较模糊,针对其他地方写入的,只读的有没有这种情况?
    sujin190
    sujin190
    Apr 27, 2020
    3
    Connection 的默认连接参数和 pymysql 是一样的,autocommit 默认为 False,如果数据库全局配置 autocommit 也为 off 的话,是需要手动 commit 才能查询到新数据的啊
    SystemLight
    SystemLight
    OP
    Apr 28, 2020
    4
    @sujin190 已解决,查到您以前的评论说过这个问题
    SystemLight
    SystemLight
    OP
    Apr 28, 2020
    5
    @baocaixiong 还真是,不过我真的第一次发现查询也需要 commit,原来以为只要插入 commit 就可以了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1731 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 03:54 · PVG 11:54 · LAX 19:54 · JFK 22:54
    ♥ Do have faith in what you're doing.