executemany(): Basic syntax

The executemany() call has the following basic syntax:

<cursor object handle>.executemany(<statement>, <arguments>)

Note that neither the statement to be processed nor its arguments is optional. Both are required; otherwise, a TypeError will be thrown by Python.

The data type of each argument to executemany() should be noted as:

  • statement: A string containing the query to execute
  • arguments: A sequence containing parameters to use within the statement

Using any other type for statements or arguments will result in Python throwing an error.

The statement may be constructed using Python's string manipulation methods. The sequence reflected in the arguments must be either of a sequence or mapping type. Thus, the following data ...

Get MySQL for Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.