The conn.open attribute will tell you whether the connection has been
explicitly closed or whether a remote close has been detected.
However, it's always possible that you will try to issue a query and
suddenly the connection is found to have given out - there is no way
to detect this ahead of time (indeed, it might happen during the
process of issuing the query), so the only truly safe thing is to wrap
your calls in a try/except block
在if语句中使用conn.connection。
可以使用Connection.open属性。
如果连接打开,则Connection.open字段为1,否则为0。所以你可以说
我认为try-and-catch可能会成功,而不是只检查游标。
相关问题 更多 >
编程相关推荐