Chapter 6. Inserting Multiple Entries
When we deal with large amounts of data that are all going into the same database, running single instances of individual INSERT
commands can take a ridiculous amount of time and waste a considerable amount of I/O. What we need is a way to insert multiple items in one go.
In this chapter, we will look at the following:
How iteration can help us execute several individual
INSERT
statements rapidlyUsing
executemany()
to submit severalINSERT
statements in one goWhen not to use
executemany()
Throttling how much data is inserted at a time
At the end of the chapter, we will put these lessons to use in writing a conversion program that inserts the contents of a comma-separated value (CSV) file into MySQL.