Re: MySQLdb如何判断数据库连接有 效?
"kun xu" <[email protected]>
| Newsgroups | gmane.comp.python.chinese |
|---|---|
| Message-ID | <[email protected]> |
谢谢各位,之前都是用抛异常的方式处理数据库可能出现连接断开的问题,现在好了,再次感谢。 在08-1-15,leopay <[email protected]> 写道: > > >>> help(MySQLdb.connection.ping) > Help on method_descriptor: > > ping(...) > Checks whether or not the connection to the server is > working. If it has gone down, an automatic reconnection is > attempted. > > This function can be used by clients that remain idle for a > long while, to check whether or not the server has closed the > connection and reconnect if necessary. > > New in 1.2.2: Accepts an optional reconnect parameter. If True, > then the client will attempt reconnection. Note that this setting > is persistent. By default, this is on in MySQL<5.0.3, and off > thereafter. > > Non-standard. You should assume that ping() performs an > implicit rollback; use only when starting a new transaction. > You have been warned. > > > On 1/15/08, leopay <[email protected]> wrote: > > > > connection.ping() > > > > On 1/15/08, luo roger <[email protected] > wrote: > > > > > > 用数据库连接池Dbutils,好像可以自动重连的。 > > > > > > 在08-1-15,kun xu <[email protected]> 写道: > > > > > > > > 做了一个程序,用到MySQLdb,这个程序需要一直保持对数据库的连接,没有在文档中看到如何判断当前数据库链接有效的函数? > > > > 有没有用过的兄弟给个提示。 > > > > > > > > _______________________________________________ > > > > python-chinese > > > > Post: send [email protected] > > > > Subscribe: send subscribe to [email protected] > > > > Unsubscribe: send unsubscribe to > > > > [email protected] > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > > > _______________________________________________ > > > python-chinese > > > Post: send [email protected] > > > Subscribe: send subscribe to [email protected] > > > Unsubscribe: send unsubscribe to > > > [email protected] > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > _______________________________________________ > python-chinese > Post: send [email protected] > Subscribe: send subscribe to [email protected] > Unsubscribe: send unsubscribe to [email protected] > Detail Info: http://python.cn/mailman/listinfo/python-chinese > _______________________________________________ python-chinese Post: send [email protected] Subscribe: send subscribe to [email protected] Unsubscribe: send unsubscribe to [email protected] Detail Info: http://python.cn/mailman/listinfo/python-chinese