1. INSERT INTO 语句的使用
import mysqldb conn = mysqldb.connect(host="127.0.0.1",port=3306,user="root",passwd="" db = "") cur = conn.cursor()
fields = ",".join(["%s" %i for i in fields_list ])
values= ",".join(["'%s'"%i for i in map(str,item for item in list)])
query = "insert into %s(%s) values (%s)"%(table,fields,values) cur.excute(query) conn.commit() cur.close() conn.close()