title: How do I insert variables in the UPDATE Statement sqlite3 with Python?
body: <p>If I want to insert a variable value in sqlite3 with python you code the following statement. For example:</p>
  
  <pre><code>import sqlite3
  import random
  
  conn = sqlite3.connect('testing.db')
  c = conn.cursor()
  c.execute("CREATE TABLE IF NOT EXISTS testing(Name TEXT, Telephone TEXT, ID REAL)")
  
  var1 = input("Value:")
  var2 = input("Value:")
  var3 = random.randint(1,20)
  
  c.execute("INSERT INTO testing VALUES(?, ?, ?)", (var1, var2, var3))
  
  conn.commit()
  conn.close()
  </code></pre>
  
  <p>What if I want to do the same with the <strong>UPDATE</strong> statement. I tried this and is giving me error:</p>
  
  <pre><code>column = input("Column to update:")
  update_user = input("Value to update:")
  field_name = input("Where field name equal to:")
  value = input("Value")
  
  c.execute("UPDATE testing SET ? = ? WHERE ? = ?", (column, update_user, field_name, value))
  
  conn.commit()
  </code></pre>
  
  <p>And this is the error that I get:</p>
  
  <pre><code>sqlite3.OperationalError: near "?": syntax error
  </code></pre>