mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 21:00:33 +03:00
rename param name to fetch
This commit is contained in:
parent
e2b99d3a8e
commit
b40ac15efc
|
@ -1198,7 +1198,7 @@ def execute_batch(cur, sql, argslist, page_size=100):
|
||||||
cur.execute(b";".join(sqls))
|
cur.execute(b";".join(sqls))
|
||||||
|
|
||||||
|
|
||||||
def execute_values(cur, sql, argslist, template=None, page_size=100, fetch_result=False):
|
def execute_values(cur, sql, argslist, template=None, page_size=100, fetch=False):
|
||||||
'''Execute a statement using :sql:`VALUES` with a sequence of parameters.
|
'''Execute a statement using :sql:`VALUES` with a sequence of parameters.
|
||||||
|
|
||||||
:param cur: the cursor to use to execute the query.
|
:param cur: the cursor to use to execute the query.
|
||||||
|
@ -1229,7 +1229,7 @@ def execute_values(cur, sql, argslist, template=None, page_size=100, fetch_resul
|
||||||
statement. If there are more items the function will execute more than
|
statement. If there are more items the function will execute more than
|
||||||
one statement.
|
one statement.
|
||||||
|
|
||||||
:param fetch_result: flag indicating that results of query execution should
|
:param fetch: flag indicating that results of query execution should
|
||||||
be returned. Useful for queries with `RETURNING` clause
|
be returned. Useful for queries with `RETURNING` clause
|
||||||
|
|
||||||
.. __: https://www.postgresql.org/docs/current/static/queries-values.html
|
.. __: https://www.postgresql.org/docs/current/static/queries-values.html
|
||||||
|
@ -1278,10 +1278,10 @@ def execute_values(cur, sql, argslist, template=None, page_size=100, fetch_resul
|
||||||
parts.append(b',')
|
parts.append(b',')
|
||||||
parts[-1:] = post
|
parts[-1:] = post
|
||||||
cur.execute(b''.join(parts))
|
cur.execute(b''.join(parts))
|
||||||
if fetch_result:
|
if fetch:
|
||||||
result.extend(cur.fetchall())
|
result.extend(cur.fetchall())
|
||||||
|
|
||||||
if fetch_result:
|
if fetch:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ class TestExecuteValues(FastExecuteTestMixin, testutils.ConnectingTestCase):
|
||||||
result = psycopg2.extras.execute_values(cur,
|
result = psycopg2.extras.execute_values(cur,
|
||||||
"insert into testfast (id, val) values %s returning id",
|
"insert into testfast (id, val) values %s returning id",
|
||||||
((i, i * 10) for i in range(25)),
|
((i, i * 10) for i in range(25)),
|
||||||
page_size=10, fetch_many=True)
|
page_size=10, fetch=True)
|
||||||
# result contains all returned pages
|
# result contains all returned pages
|
||||||
self.assertEqual([r[0] for r in result], list(range(25)))
|
self.assertEqual([r[0] for r in result], list(range(25)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user