rethinkdb-python icon indicating copy to clipboard operation
rethinkdb-python copied to clipboard

add `with` support to Python cursor

Open larkost opened this issue 9 years ago • 0 comments

The Connection class in the Python driver currently supports the Python with structure, but our Cursor class does not. I just ran into a case where it would be nice to have this. An example for clarity:

with r.db('foo').table('bar').run(conn) as full_table:
     for row in full_table:
          pass # do something in reality

While our Cursors are not that expensive, it does make sure that things get cleaned up on-time.

larkost avatar May 16 '16 22:05 larkost