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

2013-01-06 22:15:10 +08:00
 barbery
4374 次点击
所在节点    Python
5 条回复
mercurylanded
2013-01-06 22:40:55 +08:00
VYSE
2013-01-07 02:11:01 +08:00
拿到cursor前conn.ping一下,断了的话就自动重连了

http://www.neotitans.com/resources/python/mysql-python-connection-error-2006.html
ElmerZhang
2013-01-07 11:06:28 +08:00
set wait_timeout=xxxx
设置闲置连接超时时间
barbery
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
2013-01-07 13:36:58 +08:00
@barbery 这是一条 SQL 语句

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/56805

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX