def close(self):
    """Close the cursor. No further queries will be possible."""
if not self.connection:
    return
while self.nextset():
    pass
self.connection = None
Необходимость явного cursor.close()