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
Post a Comment