title: Insert multiple values in MySQL with Python from an array
body: <p>I am trying to insert data from my array into MySQL.
  To my big surprise there were not many examples on how to do it if you perform a for-loop for your array, every example that I have found was from an already existing array list.</p>
  <p>Thanks to Adrian below, we noticed that I need tuples for my list.</p>
  <p><strong>Updated code</strong></p>
  <pre><code>connection = mysql.connector.connect(
      host='localhost', 
      database='test',
      user='root', 
      password='pass'
      )
  
  query = &quot;INSERT INTO blue (created, published, publisher) VALUES (%s, %s, %s)&quot;
  
  array = []
  # The idea here is to get all table rows in the page so you can group the values into rows that are going to be added to MySQL
  tr = soup.find_all('tr')
  for table_row in tr:
      row_data = table_row.find_all('td')
      insert_row = []
      for data in row_data:
          data = re.sub('&lt;[^&gt;]*&gt;', '', str(data))
          insert_row.append(data)
      array.append(tuple(insert_row))
  print(array)
  
  cursor = connection.cursor()
  cursor.executemany(query, array)
  cursor.commit()
  </code></pre>
  <p>Getting close but at the moment I receive the following</p>
  <blockquote>
  <p>IndexError: Tuple index out of range</p>
  <p>mysql.connector.errors.ProgrammingError: Not enough parameters for the SQL statement</p>
  </blockquote>
  <p>Thanks in advance!</p>