diff --git a/doc/src/cursor.rst b/doc/src/cursor.rst index a0d66bc0..a998b3c3 100644 --- a/doc/src/cursor.rst +++ b/doc/src/cursor.rst @@ -208,6 +208,14 @@ The ``cursor`` class Parameters are bounded to the query using the same rules described in the `~cursor.execute()` method. + .. code:: python + + >>> nums = ((1,), (5,), (10,)) + >>> cur.executemany("INSERT INTO test (num) VALUES (%s)", nums) + + >>> tuples = ((123, "foo"), (42, "bar"), (23, "baz")) + >>> cur.executemany("INSERT INTO test (num, data) VALUES (%s, %s)", tuples) + .. warning:: In its current implementation this method is not faster than executing `~cursor.execute()` in a loop. For better performance diff --git a/doc/src/extras.rst b/doc/src/extras.rst index 96f801ba..083379b9 100644 --- a/doc/src/extras.rst +++ b/doc/src/extras.rst @@ -1029,6 +1029,14 @@ parameters. By reducing the number of server roundtrips the performance can be .. autofunction:: execute_batch + .. code:: python + + >>> nums = ((1,), (5,), (10,)) + >>> execute_batch(cur, "INSERT INTO test (num) VALUES (%s)", nums) + + >>> tuples = ((123, "foo"), (42, "bar"), (23, "baz")) + >>> execute_batch(cur, "INSERT INTO test (num, data) VALUES (%s, %s)", tuples) + .. versionadded:: 2.7 .. note::