Skip to content

Commit 2e8f672

Browse files
authored
Merge pull request #7 from leofiore/master
Add support for with statement using cursors
2 parents fce4e2b + 6af8d30 commit 2e8f672

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

DBUtils/SteadyDB.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,13 @@ def _setsizes(self, cursor=None):
548548
else:
549549
cursor.setoutputsize(size, column)
550550

551+
def __enter__(self):
552+
return self
553+
554+
def __exit__(self, *exc_info):
555+
del exc_info
556+
self.close()
557+
551558
def close(self):
552559
"""Close the tough cursor.
553560

0 commit comments

Comments
 (0)