Dynamically add a data field, and a method of solving mysql (based python3.6)

arr = [] #arr the list
test = ','. join ( [item for item in arr]) # here need stitching, stitching must list, if the list will be converted to a tuple, then it contains str brought into the field at the wrong (tangle one morning, really smelly sister!) 

SQL = "INSERT INTO the Customer (" + the Test + ") values (% S)"% ','. the Join ([ '% S'] * len (arr)) # SQL text the splice splicing required directly into the list, and a plurality of data needs% s, then after the data into a list of tuples can be brought
cur.execute (sql, data_insert) # successful operation

Guess you like

Origin www.cnblogs.com/setname/p/11496678.html