executemany for MySQLdb error for large number of rows <p>I'm currently running a script to insert values (a list of tuples) into a MySQL database, using the execute many function. When I use a small number of rows (`1000), the script runs fine.</p> <p>When I use around 40,000 rows, I receive the following errors:</p> <pre><code>cursor.executemany( stmt, trans_frame) Traceback (most recent call last): File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 2538, in run_code exec code_obj in self.user_global_ns, self.user_ns File "&lt;ipython-input-1-66b44e71cf5a&gt;", line 1, in &lt;module&gt; cursor.executemany( stmt, trans_frame) File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 253, in executemany r = self._query('\n'.join([query[:p], ',\n'.join(q), query[e:]])) File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 346, in _query rowcount = self._do_query(q) File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 310, in _do_query db.query(q) OperationalError: (2006, 'MySQL server has gone away') </code></pre> <p>Any suggestions?</p>