title: Python - SQLite For Loop OperationalError
body: <p>I've been given a messy Excel file that I am trying to transfer into tidied SQL tables. I am building a Python program to do the transfer. There is a list of names, some of which are repeated. I've already gotten the column with all the names into a list of tuples like:</p>
  <pre class="lang-py prettyprint-override"><code>[(John Christopher, ), (Elizabeth Smith, ), (etc, )]
  </code></pre>
  <p>I've built an SQL table called Players and have an empty column named &quot;id&quot;. I'm trying to iterate through this list and assign a unique id to each player in the Table and then also delete the duplicate names in my table.</p>
  <p>However I keep getting this error:</p>
  <pre class="lang-none prettyprint-override"><code>    cursor.execute(&quot;UPDATE Players SET id = &quot;+str(id)+&quot; WHERE name = &quot;+str(item[0]))
  sqlite3.OperationalError: near &quot;Christopher&quot;: syntax error
  </code></pre>
  <p>What is my issue?</p>
  <p>Here is the code:</p>
  <pre class="lang-py prettyprint-override"><code>import sqlite3
  
  player_list_start = cursor.execute(&quot;SELECT name FROM Players&quot;)
  saved_list = player_list_start.fetchall()
  
  # number id should start on
  id = 1
  
  # list of players to keep track if they are already in the table
  names = []
  
  for item in saved_list:
      if item[0] not in names:
          cursor.execute(&quot;UPDATE Players SET id = &quot;+str(id)+&quot; WHERE name = &quot;+str(item[0]))
          connection.commit()
          names.append(item[0])
          id += 1
      else:
          cursor.execute(&quot;DELETE FROM Players WHERE name = &quot;+str(item[0])+&quot; AND id = NULL&quot;)
          connection.commit()
  </code></pre>