On Thu, Mar 10, 2016 at 5:37 AM, Shaan Repswal
<shaun.reapswaal@gmail.com> wrote:
> #First make the appropriate column
> cur.execute("""ALTER TABLE inventory
> ADD %s integer DEFAULT NULL;""",
> [x[0].get_text()])
> #Then give that column the appropriate value for the current
> record
> cur.execute("""UPDATE inventory
> SET %s = %s
> WHERE name = %s;""", [x[0].get_text(),
> x[1].get_text(), self.entry_product_name.get_text()])
You cannot use %s to pass a table or field name: %s is only used for the values.
There is still no support for escaping values into identifier names.
There is something in the current master: the function
psycopg2.extensions.quote_ident(), but it hasn't been released yet and
the interface may change before the release.
-- Daniele