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. ;)
精彩评论