File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
Original file line number Diff line number Diff line change @@ -85,13 +85,22 @@ def __init__(self, connection):
85
85
86
86
def close (self ):
87
87
"""Close the cursor. No further queries will be possible."""
88
- if self .connection is None or self .connection () is None :
89
- return
90
- while self .nextset ():
91
- pass
92
- self .connection = None
93
- self .errorhandler = None
94
- self ._result = None
88
+ try :
89
+ if self .connection is None or self .connection () is None :
90
+ return
91
+ while self .nextset ():
92
+ pass
93
+ finally :
94
+ self .connection = None
95
+ self .errorhandler = None
96
+ self ._result = None
97
+
98
+ def __enter__ (self ):
99
+ return self
100
+
101
+ def __exit__ (self , * exc_info ):
102
+ del exc_info
103
+ self .close ()
95
104
96
105
def _check_executed (self ):
97
106
if not self ._executed :
You can’t perform that action at this time.
0 commit comments