|
[psycopg] #99: Patch for cursor.execute and cursor.executemany to return cu: msg#00001python.db.psycopg.devel
#99: Patch for cursor.execute and cursor.executemany to return cursor object -------------------------------------------------+-------------------------- Reporter: Miki Tebeka <miki.tebeka@xxxxxxxxx> | 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 }}} The patch: {{{ Index: cursor_type.c =================================================================== --- cursor_type.c (revision 745) +++ cursor_type.c (working copy) @@ -395,6 +395,7 @@ { long int async = 0; PyObject *vars = NULL, *operation = NULL; + PyObject *pyself = NULL; static char *kwlist[] = {"query", "vars", "async", NULL}; @@ -425,8 +426,9 @@ EXC_IF_CURS_CLOSED(self); if (_psyco_curs_execute(self, operation, vars, async)) { - Py_INCREF(Py_None); - return Py_None; + pyself = (PyObject *)self; + Py_INCREF(pyself); + return pyself; } else { return NULL; @@ -441,6 +443,7 @@ { PyObject *operation = NULL, *vars = NULL; PyObject *v, *iter = NULL; + PyObject *pyself = NULL; static char *kwlist[] = {"query", "vars", NULL}; @@ -473,8 +476,9 @@ } Py_XDECREF(iter); - Py_INCREF(Py_None); - return Py_None; + pyself = (PyObject *)self; + Py_INCREF(pyself); + return pyself; } }}} -- Ticket URL: <http://initd.org/tracker/psycopg/ticket/99> psycopg <http://initd.org/> psycopg_______________________________________________ Psycopg mailing list Psycopg-IAPFreCvJWPBWskQ1e/+sw@xxxxxxxxxxxxxxxx http://lists.initd.org/mailman/listinfo/psycopg |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [psycopg] #98: 'raise' is better than 'raise err' when reraising errors.: 00001, psycopg |
|---|---|
| Next by Date: | Re: [psycopg] #99: Patch for cursor.execute and cursor.executemany to return cursor object: 00001, psycopg |
| Previous by Thread: | [psycopg] #98: 'raise' is better than 'raise err' when reraising errors.i: 00001, psycopg |
| Next by Thread: | Re: [psycopg] #99: Patch for cursor.execute and cursor.executemany to return cursor object: 00001, psycopg |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |