Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Dynamische MySQL-Abfrageanweisung in Python

cursor.execute('INSERT INTO media_files (%s) VALUES (%%s, %%s, %%s, %%s,   ...)' % ','.join(fieldlist), valuelist)

Um es klarer zu machen:

sql = 'INSERT INTO media_files (%s) VALUES (%%s, %%s, %%s, %%s,   ...)' % ','.join(fieldlist)
cursor.execute(sql, valuelist)