mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-26 10:53:44 +03:00
.executemany() fixes.
This commit is contained in:
parent
19c5129d5b
commit
30b2ba6ebf
|
@ -46,8 +46,7 @@ data = [('Tom', 'Jenkins', '37'),
|
||||||
('Madonna', None, '45'),
|
('Madonna', None, '45'),
|
||||||
('Federico', 'Di Gregorio', None)]
|
('Federico', 'Di Gregorio', None)]
|
||||||
query = "INSERT INTO test_copy VALUES (%s, %s, %s)"
|
query = "INSERT INTO test_copy VALUES (%s, %s, %s)"
|
||||||
for row in data:
|
curs.executemany(query, data)
|
||||||
curs.execute(query, row)
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
# copy_to using defaults
|
# copy_to using defaults
|
||||||
|
|
|
@ -433,7 +433,7 @@ psyco_curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs)
|
||||||
|
|
||||||
static char *kwlist[] = {"query", "vars", NULL};
|
static char *kwlist[] = {"query", "vars", NULL};
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Oi", kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", kwlist,
|
||||||
&operation, &vars)) {
|
&operation, &vars)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,7 @@ psyco_curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs)
|
||||||
|
|
||||||
for (i = 0; i < PySequence_Size(vars); i++) {
|
for (i = 0; i < PySequence_Size(vars); i++) {
|
||||||
PyObject *v = PySequence_GetItem(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);
|
Py_XDECREF(v);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user