diff options
author | Federico Di Gregorio <fog@initd.org> | 2005-03-12 09:19:59 +0000 |
---|---|---|
committer | Federico Di Gregorio <fog@initd.org> | 2005-03-12 09:19:59 +0000 |
commit | 30b2ba6ebf30f54b02b649a4d6a8b1c23de4345b (patch) | |
tree | 6ed5194488d6446910e08270c60b6b25305b3489 | |
parent | 19c5129d5bd37af6806869f063875c85ae0d9b40 (diff) | |
download | psycopg2-30b2ba6ebf30f54b02b649a4d6a8b1c23de4345b.tar.gz |
.executemany() fixes.1_99_13
-rw-r--r-- | examples/copy_to.py | 3 | ||||
-rw-r--r-- | psycopg/cursor_type.c | 4 |
2 files changed, 3 insertions, 4 deletions
diff --git a/examples/copy_to.py b/examples/copy_to.py index f4433ed..2eea672 100644 --- a/examples/copy_to.py +++ b/examples/copy_to.py @@ -46,8 +46,7 @@ data = [('Tom', 'Jenkins', '37'), ('Madonna', None, '45'), ('Federico', 'Di Gregorio', None)] query = "INSERT INTO test_copy VALUES (%s, %s, %s)" -for row in data: - curs.execute(query, row) +curs.executemany(query, data) conn.commit() # copy_to using defaults diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index 66908fc..08895bc 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -433,7 +433,7 @@ psyco_curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs) static char *kwlist[] = {"query", "vars", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Oi", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", kwlist, &operation, &vars)) { return NULL; } @@ -442,7 +442,7 @@ psyco_curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs) for (i = 0; i < PySequence_Size(vars); i++) { PyObject *v = PySequence_GetItem(vars, i); - if (!v || _psyco_curs_execute(self, operation, vars, 0) == 0) { + if (!v || _psyco_curs_execute(self, operation, v, 0) == 0) { Py_XDECREF(v); return NULL; } |