I have a dictionary of database names. I take a name from the dictionary
database_name = database_dict[i]
lets say the value for database_name is 'foo'
Using Psycopg2 I am executing a statement:
cur.execute("INSERT INTO %s VALUES(...);", database_name)
I get A syntax error at foo, because it should be "INSERT INTO foo VALUES" not "INSERT INTO 'foo' VALUES"
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?
EDIT: Something closer is here: How do I remove single quotes from a table in postgresql?
but I could not get it to work using REMOVE. It gave a syntax error at the single quote inside the remove statement.