I tried to pass parameters the way it is described in the docs, but I get the following error: File "slug_word.py", line 100, in get_col cur.execute("select %s from %s" , data ) psycopg2.ProgrammingError: syntax error at or near "E'catalog_category'" LINE 1: select E'slug' from E'catalog_category'
Here are extracts from my code:
def get_col(cxn, table, col):
"fetch a column"
cur = cxn.cursor()
data = (col, table)
cur.execute("select %s from %s" , data )
rows = cur.fetchall()
return rows
def main():
cxn = connect('galleria')
table = 'catalog_category'
col = 'slug'
rows = get_col(cxn, table, col)