summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/copy_to.py3
-rw-r--r--psycopg/cursor_type.c4
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;
}