Python Mysqldb Cursor.execute() Insert With Varying Number Of Values
Similar questions have been asked, but all of them - for example This One deals only with specified number of values. for example, I tried to do this the following way: def insert_
Solution 1:
You should use string interpolation to produce placeholders for the content, then allow the DB-API to populate them. For example:
placeholders = ','.join('%s' for col in columns)
query_string = "INSERT INTO `{}` {} VALUES ({})".format(table, columns, placeholders)
query.execute(query_string, values)
Post a Comment for "Python Mysqldb Cursor.execute() Insert With Varying Number Of Values"