@@ -851,9 +851,11 @@ def executemany(
851851        self ,
852852        statement : Optional [str ],
853853        parameters : Any ,
854+         * ,
854855        batcherrors : bool  =  False ,
855856        arraydmlrowcounts : bool  =  False ,
856857        suspend_on_success : bool  =  False ,
858+         batch_size : int  =  2 ** 32  -  1 ,
857859    ) ->  None :
858860        """ 
859861        Executes a SQL statement once using all bind value mappings or 
@@ -900,21 +902,35 @@ def executemany(
900902        sessionless transaction will be suspended when ``executemany()`` 
901903        completes successfully. See :ref:`suspendtxns`. 
902904
905+         The ``batch_size`` parameter is used to split large data sets into 
906+         smaller pieces for sending to the database. It is the number of records 
907+         in each batch. This parameter can be used to tune performance. When 
908+         ``Connection.autocommit`` is *True*, a commit will take place for each 
909+         batch. 
910+ 
903911        For maximum efficiency, it is best to use the :meth:`setinputsizes()` 
904912        method to specify the bind value types and sizes. In particular, if the 
905913        type is not explicitly specified, the value *None* is assumed to be a 
906914        string of length 1 so any values that are later bound as numbers or 
907915        dates will raise a TypeError exception. 
908916        """ 
909917        self ._verify_open ()
910-         num_execs  =  self ._impl ._prepare_for_executemany (
911-             self , self ._normalize_statement (statement ), parameters 
918+         manager  =  self ._impl ._prepare_for_executemany (
919+             self ,
920+             self ._normalize_statement (statement ),
921+             parameters ,
922+             batch_size ,
912923        )
913924        self ._impl .suspend_on_success  =  suspend_on_success 
914-         if   num_execs  >  0 :
925+         while   manager . num_rows  >  0 :
915926            self ._impl .executemany (
916-                 self , num_execs , bool (batcherrors ), bool (arraydmlrowcounts )
927+                 self ,
928+                 manager .num_rows ,
929+                 batcherrors ,
930+                 arraydmlrowcounts ,
931+                 manager .message_offset ,
917932            )
933+             manager .next_batch ()
918934
919935    def  fetchall (self ) ->  list :
920936        """ 
@@ -1188,9 +1204,11 @@ async def executemany(
11881204        self ,
11891205        statement : Optional [str ],
11901206        parameters : Any ,
1207+         * ,
11911208        batcherrors : bool  =  False ,
11921209        arraydmlrowcounts : bool  =  False ,
11931210        suspend_on_success : bool  =  False ,
1211+         batch_size : int  =  2 ** 32  -  1 ,
11941212    ) ->  None :
11951213        """ 
11961214        Executes a SQL statement once using all bind value mappings or 
@@ -1236,21 +1254,32 @@ async def executemany(
12361254        sessionless transaction will be suspended when ``executemany()`` 
12371255        completes successfully. See :ref:`suspendtxns`. 
12381256
1257+         The ``batch_size`` parameter is used to split large data sets into 
1258+         smaller pieces for sending to the database. It is the number of records 
1259+         in each batch. This parameter can be used to tune performance. When 
1260+         ``Connection.autocommit`` is *True*, a commit will take place for each 
1261+         batch. Do not set ``batch_size`` when ``suspend_on_success`` is *True*. 
1262+ 
12391263        For maximum efficiency, it is best to use the :meth:`setinputsizes()` 
12401264        method to specify the parameter types and sizes ahead of time. In 
12411265        particular, the value *None* is assumed to be a string of length 1 so 
12421266        any values that are later bound as numbers or dates will raise a 
12431267        TypeError exception. 
12441268        """ 
12451269        self ._verify_open ()
1246-         num_execs  =  self ._impl ._prepare_for_executemany (
1247-             self , self ._normalize_statement (statement ), parameters 
1270+         manager  =  self ._impl ._prepare_for_executemany (
1271+             self , self ._normalize_statement (statement ), parameters ,  batch_size 
12481272        )
12491273        self ._impl .suspend_on_success  =  suspend_on_success 
1250-         if   num_execs  >  0 :
1274+         while   manager . num_rows  >  0 :
12511275            await  self ._impl .executemany (
1252-                 self , num_execs , bool (batcherrors ), bool (arraydmlrowcounts )
1276+                 self ,
1277+                 manager .num_rows ,
1278+                 batcherrors ,
1279+                 arraydmlrowcounts ,
1280+                 manager .message_offset ,
12531281            )
1282+             manager .next_batch ()
12541283
12551284    async  def  fetchall (self ) ->  list :
12561285        """ 
0 commit comments