@@ -72,6 +72,7 @@ MySQL C API function mapping
7272 ``mysql_get_server_info() `` ``conn.get_server_info() ``
7373 ``mysql_info() `` ``conn.info() ``
7474 ``mysql_insert_id() `` ``conn.insert_id() ``
75+ ``mysql_more_results() `` ``conn.more_results() ``
7576 ``mysql_num_fields() `` ``result.num_fields() ``
7677 ``mysql_num_rows() `` ``result.num_rows() ``
7778 ``mysql_options() `` various options to ``_mysql.connect() ``
@@ -321,6 +322,27 @@ connect(parameters...)
321322 overridden. Default: ``MySQLdb.cursors.Cursor ``. *This
322323 must be a keyword parameter. *
323324
325+ executemany_fallback
326+ Controls how ``Cursor.executemany() `` handles statements that
327+ cannot use the multi-row INSERT/REPLACE optimization. ``"loop" ``
328+ executes the statements one at a time and is the default.
329+ ``"multi" `` may combine safe data manipulation statements into a
330+ multi-statement query. If multi-statements are disabled or a query
331+ is not eligible, execution silently falls back to ``"loop" ``.
332+
333+ This is a connection option so it can be passed through, for
334+ example, SQLAlchemy's ``connect_args `` or Django's database
335+ ``OPTIONS ``::
336+
337+ create_engine(
338+ "mysql+mysqldb://user:password@host/database",
339+ connect_args={"executemany_fallback": "multi"},
340+ )
341+
342+ DATABASES["default"]["OPTIONS"]["executemany_fallback"] = "multi"
343+
344+ See ``executemany() `` below for batching and transaction details.
345+
324346 use_unicode
325347 If True, CHAR and VARCHAR and TEXT columns are returned as
326348 Unicode strings, using the configured character set. It is
@@ -562,6 +584,31 @@ close()
562584 close the cursor when you are done with it and before creating a
563585 new one.
564586
587+ executemany(operation, seq_of_params)
588+ Executes an operation for every parameter set and returns the total
589+ number of affected rows. Multi-row INSERT and REPLACE statements use
590+ MySQLdb's existing single-statement ``VALUES `` rewrite whenever it
591+ applies, independently of ``executemany_fallback ``.
592+
593+ With ``executemany_fallback="multi" ``, statements that do not match that
594+ rewrite may instead be sent in multi-statement batches. This applies only
595+ to SQL templates which begin with INSERT, REPLACE, UPDATE, or DELETE
596+ (ignoring leading whitespace), contain no semicolon, and contain no
597+ ``RETURNING `` clause. Other statements, including statements beginning
598+ with a comment or ``WITH ``, use the normal loop. The loop is also used
599+ silently when the connection does not have multi-statements enabled.
600+
601+ Each batch is limited to 16000 encoded bytes, including separators, and
602+ 200 statements. A single rendered statement exceeding the byte limit is
603+ executed alone. On successful completion, ``rowcount `` and the return
604+ value are the sum of the affected-row counts for all statements.
605+
606+ Batching does not create an implicit transaction and is not atomic. If a
607+ statement fails, statements before it may already have executed, while
608+ statements after it do not execute. Applications needing all-or-nothing
609+ behavior must manage a transaction explicitly; with autocommit enabled,
610+ each statement may be committed independently.
611+
565612info()
566613 Returns some information about the last query. Normally
567614 you don't need to check this. If there are any MySQL
0 commit comments