Name

executemany( )

Signature

                        cursor.executemany(sql,parameters)

Synopsis

Prepares an SQL statement and sends it to MySQL for execution against all parameter sequences or mappings in the parameters sequence.

Example

connection = MySQLdb.connect(host='carthage', user='test', 
                             passwd='test', db='test');
cursor = connection.cursor(  );
cursor.executemany("INSERT INTO COLOR ( COLOR, ABBREV ) VALUES (%s, %s )",
                   (("BLUE", "BL"), ("PURPLE", "PPL"), ("ORANGE", "ORN")));

Get Managing & Using MySQL, 2nd Edition 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.