开发者

How to check if a MySQL connection is closed in Python?

开发者 https://www.devze.com 2023-01-09 09:39 出处:网络
The question says everything. How can I check if my MySQL connection is closed in P开发者_开发技巧ython?

The question says everything. How can I check if my MySQL connection is closed in P开发者_开发技巧ython?

I'm using MySQLdb, see http://mysql-python.sourceforge.net/


The Connection.open field will be 1 if the connection is open and 0 otherwise. So you can say

if conn.open:
    # do something
0

精彩评论

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

关注公众号