|
Re: #99: Patch for cursor.execute and cursor.executemany to return cursor o: msg#00003python.db.psycopg.devel
Miki Tebeka wrote: >#99: Patch for cursor.execute and cursor.executemany to return cursor object >-------------------------------------------------+-------------------------- > Reporter: Miki Tebeka <miki.tebeka-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx> > | Owner: fog > Type: defect | Status: new > Priority: normal | Milestone: PSYCOPG 2.0 >Component: psycopg2 | Version: 2.0beta > Severity: patch | Keywords: >-------------------------------------------------+-------------------------- > This patch makes `cursor.execute` and `cursor.executemany` return the > cursor object. > This way you can write: > {{{ > #!python > for login, in cursor.execute("select login from users"): > print login > }}} > > I assume that you really meant to write this: for login, in cursor.execute("select login from users").fetchone(): print login which does save a few keystrokes over the current: cursor.execute("select login from users") for login, in cursor.fetchone(): print login Although there is some appeal to the one-liner approach, it is important to remember that most of the external interface of psycopg is not actually dictated by psycopg: it's the Python DBAPI. We can't arbitrarily invent new behaviors. I agree with Federico on this. Some day, the DBAPI crew may decide that execute() should return something (success/failure code? record count? I don't know), and psycopg needs to be able to respond to that without breaking existing applications. -- Tim Roberts, timr-EQQNi8F+HVEAvxtiuMwx3w@xxxxxxxxxxxxxxxx Providenza & Boekelheide, Inc. |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [psycopg] #99: Patch for cursor.execute and cursor.executemany to return cursor object: 00003, psycopg |
|---|---|
| Next by Date: | Re: #99: Patch for cursor.execute and cursor.executemany to return cursor object: 00003, PFC |
| Previous by Thread: | Re: [psycopg] #99: Patch for cursor.execute and cursor.executemany to return cursor objecti: 00003, psycopg |
| Next by Thread: | Re: #99: Patch for cursor.execute and cursor.executemany to return cursor object: 00003, PFC |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |