Hi all, I was wondering whether there has been any particular reason that the specification of the Cursor object doesn’t implement a context manager to enable for example the “with” statement? Being able to use the “with” statement for database cursors, just like other external resources like files, etc., I think makes a lot of sense:
with conn.cursor() as c: c.execute("SELECT 'test' from dual") result = c.fetchall() print(result) Currently this results in an AttributeError: File “/Users/gvenzl/test/test.py”, line 23, in test with conn.cursor() as c: AttributeError: __exit__ Thx, --------------- Gerald Venzl | Senior Principal Product Manager Email: gerald.ve...@oracle.com <mailto:gerald.ve...@oracle.com> | Phone: +1.650.633.0085 <tel:+16506330085> Oracle ST & Database Development 400 Oracle Parkway | Redwood Shores | 94065 | USA
_______________________________________________ DB-SIG maillist - DB-SIG@python.org https://mail.python.org/mailman/listinfo/db-sig