[Sqlalchemy-tickets] Issue #4077: Implementing next on ResultProxy (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
From: Philip M. <iss...@bi...> - 2017-09-14 22:15:49
|
New issue 4077: Implementing next on ResultProxy https://bitbucket.org/zzzeek/sqlalchemy/issues/4077/implementing-next-on-resultproxy Philip Martin: Since ResultProxy references a DB API cursor is there any reason why the next protocol is not implemented on ResultProxy? Given it can iterator over query results in a loop, it seems to me that it would make sense from a Python language standpoint if it implemented __next__. I am not aware of how other DB API cursors operate but using psycopg2 one could: ```python import psycopg2 select_statement = 'select * from some_table' conn = psycopg2.connect() cursor = conn.cursor() cursor.execute(select_statement) next(cursor) ``` Whereas in Sqlalchemy, calling next on the result issues a TypeError: ```python from sqlalchemy import create_engine engine = create_engine() conn = engine.connect() results = conn.execute(select_query) next(results) ``` |