title: How to use a string variable in psycopg2 select query?
body: <p>Error while fetching data from PostgreSQL column "u62194" does not
  exist</p>
  
  <pre><code>sql = """select userid from myusers WHERE userid='u62194' """ Of
  course the hardcoded value works as it should.
  
  import psycopg2
  
  def select_tables():
      someuserid = 'u62194'
      print(someuserid)
      """ Run a select using a variable that is a string """
      sql = """select userid from myusers WHERE userid=%s """ %someuserid
      conn = None
      try:
          conn = psycopg2.connect(user = "postgres",
                password = "xxxxxx",
                host = "127.0.0.1",
                port = "5432",
                database = "mydb")
          cur = conn.cursor()
          cur.execute(sql, (select_tables,))
          print(cur.fetchone())
          cur.close()
  
      """ "myusers" table: id     userid 1      u51884 2      u62194 3      u26922  """
  </code></pre>
  
  <p>I should get: u62194</p>