Skip to content

Commit 833573e

Browse files
committed
Add close and supprt of with expression for cursor
1 parent d806b38 commit 833573e

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

wherobots/db/cursor.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,18 @@ def fetchmany(self, size: int = None):
7777
def fetchall(self):
7878
return self.__get_results()[self.__current_row :]
7979

80+
def close(self):
81+
"""Close the cursor."""
82+
pass
83+
8084
def __iter__(self):
8185
return self
8286

8387
def __next__(self):
8488
raise StopIteration
89+
90+
def __enter__(self):
91+
return self
92+
93+
def __exit__(self, exc_type, exc_val, exc_tb):
94+
self.close()

0 commit comments

Comments
 (0)