vous pouvez utiliser executemany
pour regrouper le travail comme suit
import csv
import MySQLdb
db = MySQLdb.connect( host = "dbname.description.host.com",
user = "user",
passwd = "key",
db = "dbname")
cursor = db.cursor()
query = 'INSERT INTO table_name(column,column_1,column_2,column_3)
VALUES(%s, %s, %s, %s)'
csv_data = csv.reader(file('file_name'))
my_data = []
for row in csv_data:
my_data.append(tuple(row))
cursor.executemany(query, my_data)
cursor.close()