title: pyMySQL: How to check if connection is already opened or close
body: <p>I am getting the error <code>InterfaceError (0, '')</code>. Is there way in <code>Pymysql</code> library I can check whether connection or cursor is closed. For cursor I am already using context manager like that:</p>
  
  <pre><code>with db_connection.cursor() as cursor:
    ....
  </code></pre>