python - How to pass a list of *columns* to MySQLDb execute -


it's possible pass tuple mysqldb use in in clause, possible pass tuple use column list? doesn't work:

cursor.execute("select %s users", tuple(columns)) operationalerror: (1241, 'operand should contain 1 column(s)') 

it seems execute not syntax-aware replacement of lists.

ugly functional:

cursor.execute(     "select %s users" % \     ', '.join('`' + mysqldb.escape_string(column) + '`' column in columns)) 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -