title: How to add data to columns in SQLite?
body: <p>I have rewritten my "death-row" program to add a few improvements and make it compatible with Python 3.</p>
  
  <p>This is how it looks right now:</p>
  
  <pre><code>import sqlite3
  import re
  import urllib.request
  from bs4 import BeautifulSoup
  import requests
  import string
  
  URL=[]
  
  conn = sqlite3.connect('prison.sqlite') 
  conn.text_factory = str
  cur = conn.cursor() 
  cur.execute("DROP TABLE IF EXISTS prison")
  cur.execute("CREATE TABLE Prison (Execution text,Statement text, LastName text, Firstname text, TDCJNumber text, Age integer, Date text, Race text, County text)")
  conn.commit()
  url='http://www.tdcj.state.tx.us/death_row/dr_executed_offenders.html'
  lines = urllib.request.urlopen(url)
  prisondata = lines.read()
  lines.close()
  soup = BeautifulSoup(prisondata,"html.parser")
  rows = soup.find_all('tr')
  url2 = url[:38]
  for row in rows:
      td = row.find_all('td')
      try:
          Execution = str(td[0].get_text())
          cur.execute("INSERT OR IGNORE INTO prison (Execution) VALUES(?);", (str(Execution),))
          lastname= str(td[3].get_text())
          cur.execute("INSERT OR IGNORE INTO prison (Execution) VALUES(?);", (str(Execution),))
          firstname= str(td[4].get_text())
          cur.execute("INSERT OR IGNORE INTO prison (Firstname) VALUES(?);", (str(firstname),))
          tdcj= str(td[5].get_text())
          cur.execute("INSERT OR IGNORE INTO prison (TDCJNumber) VALUES(?);", (str(tdcj),))
          Age= str(td[6].get_text())
          cur.execute("INSERT OR IGNORE INTO prison (Age) VALUES(?);", (str(Age),))
          Date= str(td[7].get_text())
          cur.execute("INSERT OR IGNORE INTO prison (Date) VALUES(?);", (str(Date),))
          Race= str(td[8].get_text())
          cur.execute("INSERT OR IGNORE INTO prison (Race) VALUES(?);", (str(Race),))
          County= str(td[9].get_text())
          cur.execute("INSERT OR IGNORE INTO prison (County) VALUES(?);", (str(County),))
          links = row.find_all("a")
          link = links[1].get("href")
          LastStatementLink = url2 + link
          lines2 = urllib.request.urlopen(LastStatementLink)
          URL.append(LastStatementLink)
  
      except Exception:
          print ("An error has occured")
          continue
  
  for U in URL:
      try:
          r = requests.get(U) 
          r.raise_for_status() 
          print ("URL OK"), U
          document = urllib.request.urlopen(U)
          html = document.read()
          soup = BeautifulSoup(html,"html.parser")
          pattern = re.compile("Last Statement:") 
          Statement = soup.find(text=pattern).findNext('p').contents[0]
          print (Statement.encode("utf-8"))
          cur.execute("INSERT OR IGNORE INTO prison (Statement) VALUES(?);", (str(Statement),))
          continue 
      except requests.exceptions.HTTPError as err:
          print (err)
  
  conn.commit()
  conn.close()
  </code></pre>
  
  <p>I have been trying for hours to get the correct data inserted in the SQLite)database, but I can't seem to get it right. For example:</p>
  
  <pre><code> for row in rows:
          td = row.find_all('td')
          try:
              Execution = str(td[0].get_text())
              cur.execute("INSERT OR IGNORE INTO prison (Execution) VALUES(?);", (str(Execution),))
  </code></pre>
  
  <p>The program has to find all the execution numbers in the table at stated website at position [0] and add it to the Database in the column "Execution" It has to do this for all the other parts of the data as well.</p>
  
  <p>The problem is that python seems to create a new row every time it has to add a piece of data to the database. The program runs, but I have 4000 rows instead of around 540 in my SQLite-database.</p>
  
  <p>I've tried multiple things, but I can't seem to get the data into the right columns, or end up with the correct amount of rows.</p>
  
  <p>I've been thinking of a different approach: adding the pieces of data to lists and after that, add them to the database. This mean I would have 8 lists of data (one list for each execution number, firstname, lastname,...) But how do I add data from a list to SQLite? </p>
  
  <p>Thanks! </p>