开发者

Verify the connection with MySQL database

I using MySQLdb for access to mysql database from python. I need to know if connection with database is still alive... are there any attribute or method 开发者_如何学JAVAin order to do this???

thanks!!


To be honest, I haven't used mysqldb in python in a very long time.

That being said, I would suggest using an execute("now()") (or "select 1", any other "dummy" SQL command) and handle any errors.

edit: That should also probably be part of a class you're using. Don't fill your entire project with .execute("now()") on every other line. ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜