I'm using MySQL Connector/Python 1.0.11 with Python 3.3 and MySQL 5.6.12 to load a csv file into a table via cursor.executemany('INSERT INTO ... VALUES'). With sqlite3 or psycopg2 I can pass a _csv.reader object for seq_of_parameters, but MySQL fails with:
mysql.connector.errors.ProgrammingError: Parameters for query must be list or tuple.
Fair enough, as the docs say it must be a sequence, and the _csv.reader object is an enumerator (it defines iter and next), not a sequence. I could obviously pass 'list(my_csv_reader)', but I'm pretty sure that is not lazy, and these files can have 10^6+ rows. Is there a way to pass that lazily? Or am I wasting my time because executemany() will expand the list before performing the INSERT? (A hint from cursor.py: "INSERT statements are optimized by batching the data, that is using the MySQL multiple rows syntax.") Maybe something like wrapping the iterator in a generator, ala http://www.logarithmic.net/pfh/blog/01193268742 . I'm very much looking forward to your thoughts!