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
barbery
V2EX  ›  Python

SAE下 使用MySQLdb 常常报错 OperationalError: (2006, 'MySQL server has gone away'),MySQLdb 下木有max_idle_time 肿么办?

  •  
  •   barbery ·
    barbery · 2013-01-06 22:15:10 +08:00 · 4364 次点击
    这是一个创建于 4126 天前的主题,其中的信息可能已经有所发展或是发生改变。
    5 条回复    1970-01-01 08:00:00 +08:00
    VYSE
        2
    VYSE  
       2013-01-07 02:11:01 +08:00   ❤️ 1
    拿到cursor前conn.ping一下,断了的话就自动重连了

    http://www.neotitans.com/resources/python/mysql-python-connection-error-2006.html
    ElmerZhang
        3
    ElmerZhang  
       2013-01-07 11:06:28 +08:00
    set wait_timeout=xxxx
    设置闲置连接超时时间
    barbery
        4
    barbery  
    OP
       2013-01-07 13:10:23 +08:00
    @mercurylanded 谢谢回答,你这个文章我看过,不过就像我标题所说 MySQLdb 下木有max_idle_time 。
    @VYSE 灰常谢谢!!!貌似是正解!!!
    @ElmerZhang set wait_timeout=xxxx 我看了手册:http://mysql-python.sourceforge.net/MySQLdb.html 找不到这个属性啊亲
    ElmerZhang
        5
    ElmerZhang  
       2013-01-07 13:36:58 +08:00
    @barbery 这是一条 SQL 语句
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5406 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 05:59 · PVG 13:59 · LAX 22:59 · JFK 01:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.