title: How to remove the quotes from a string for SQL query in Python?
body: <p>I have a dictionary of database names.  I take a name from the dictionary</p>
  
  <pre><code>database_name = database_dict[i]
  </code></pre>
  
  <p>lets say the value for database_name is 'foo'</p>
  
  <p>Using Psycopg2 I am executing a statement:</p>
  
  <pre><code>cur.execute("INSERT INTO %s VALUES(...);", database_name)
  </code></pre>
  
  <p>I get A syntax error at foo, because it should be "INSERT INTO foo VALUES" not "INSERT INTO 'foo' VALUES"</p>
  
  <p>Any advice how to pass in a string value for the name of the table and removing the single quotes?  Should I place an escape character inside my database dictionary values?</p>
  
  <p>EDIT: Something closer is here: <a href="https://stackoverflow.com/questions/8587162/how-do-i-remove-single-quotes-from-a-table-in-postgresql">How do I remove single quotes from a table in postgresql?</a></p>
  
  <p>but I could not get it to work using REMOVE.  It gave a syntax error at the single quote inside the remove statement.</p>