Exemple #1
0
    async def close(self):
        """Close the connection.

        The connection will be unusable from this
        point forward; an Error exception will be raised if any operation
        is attempted with the connection. The same applies to all cursor
        objects trying to use the connection.  Note that closing a connection
        without committing the changes first will cause an implicit rollback
        to be performed.
        """
        if self.mapi:
            if not self.autocommit:
                self.rollback()
            await self.mapi.disconnect()
            self.mapi = None
        else:
            raise exceptions.Error("already closed")
Exemple #2
0
 def closed(self):
     """ check if there is a connection with a server """
     if not self.mapi:
         raise exceptions.Error("connection closed")
     return True