title: SQL multiple inserts with Python
body: <p><strong>UPDATE</strong><br>
  After passing execute() a list of rows as per Nathan's suggestion, below, the code executes further but still gets stuck on the execute function. The error message reads:</p>
  
  <pre><code>    query = query % db.literal(args)
  TypeError: not all arguments converted during string formatting
  </code></pre>
  
  <p>So it still isn't working. Does anybody know why there is a type error now?<br>
  <strong>END UPDATE</strong></p>
  
  <p>I have a large mailing list in .xls format. I am using python with xlrd to retrieve the name and email from the xls file into two lists. Now I want to put each name and email into a mysql database. I'm using MySQLdb for this part. Obviously I don't want to do an insert statement for every list item.<br>
  <strong>Here's what I have so far.</strong></p>
  
  <pre><code>from xlrd import open_workbook, cellname
  import MySQLdb
  
  dbname = 'h4h'
  host = 'localhost'
  pwd = 'P@ssw0rd'
  user = 'root'
  
  book = open_workbook('h4hlist.xls')
  sheet = book.sheet_by_index(0)
  mailing_list = {}
  name_list = []
  email_list = []
  
  for row in range(sheet.nrows):
      """name is in the 0th col. email is the 4th col."""
      name = sheet.cell(row, 0).value  
      email =  sheet.cell(row, 4).value
      if name and email:
          mailing_list[name] = email
  
  for n, e in sorted(mailing_list.iteritems()):
      name_list.append(n)
      email_list.append(e)
  
  db = MySQLdb.connect(host=host, user=user, db=dbname, passwd=pwd)
  cursor = db.cursor()
  cursor.execute("""INSERT INTO mailing_list (name,email) VALUES (%s,%s)""",
                (name_list, email_list))
  </code></pre>
  
  <p>The problem when the cursor executes. This is the error: <code>_mysql_exceptions.OperationalError: (1241, 'Operand should contain 1 column(s)')</code> I tried putting my query into a var initially, but then it just barfed up a message about passing a tuple to execute(). </p>
  
  <p><strong>What am I doing wrong? Is this even possible?</strong></p>
  
  <p>The list is huge and I definitely can't afford to put the insert into a loop. I looked at using LOAD DATA INFILE, but I really don't understand how to format the file or the query and my eyes bleed when I have to read MySQL docs. I know I <em>could</em> probably use some online xls to mysql converter, but this is a learning exercise for me as well. <strong>Is there a better way</strong>?</p>