Using pysqlite I am making a procedure to do something with some data. The same kind of operation is done on similar fields in multiple tables and columns, so I thought I co
You simply can not use placeholders for column or table names. I don't have a authoritative citation for this -- I "know" this only from having tried it and from failing. It makes some sense though:
execute-ing) the SQL statement before fetching, since all parts of the statement could be
replaced.In short, you've found the right way -- use string formating.
c.execute('SELECT {} FROM {} WHERE id=?'.format(column, table), row))
1 Not all drivers quote parameters -- oursql doesn't, since it sends SQL and arguments to the server separately.