V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2020-04-26 14:54:00 +08:00 · 1525 次点击
    这是一个创建于 1454 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    5 条回复    2020-04-28 12:58:21 +08:00
    baocaixiong
        1
    baocaixiong  
       2020-04-26 20:06:21 +08:00
    没 commit 吧
    hushao
        2
    hushao  
       2020-04-26 21:06:46 +08:00
    描述的比较模糊,针对其他地方写入的,只读的有没有这种情况?
    sujin190
        3
    sujin190  
       2020-04-27 14:07:33 +08:00
    Connection 的默认连接参数和 pymysql 是一样的,autocommit 默认为 False,如果数据库全局配置 autocommit 也为 off 的话,是需要手动 commit 才能查询到新数据的啊
    SystemLight
        4
    SystemLight  
    OP
       2020-04-28 12:56:58 +08:00
    @sujin190 已解决,查到您以前的评论说过这个问题
    SystemLight
        5
    SystemLight  
    OP
       2020-04-28 12:58:21 +08:00
    @baocaixiong 还真是,不过我真的第一次发现查询也需要 commit,原来以为只要插入 commit 就可以了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   976 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 19:39 · PVG 03:39 · LAX 12:39 · JFK 15:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.