1. 程式人生 > >python 批量JSON資料,插入資料庫

python 批量JSON資料,插入資料庫

newList=[{"link":"https://www.1.com/","ga_tag":"xvideos","image":"http://static.2.mobi/views/images/xvideos.png?x-oss-process=style/120"},{"link":"https://www.3.com/","ga_tag":"xnxx","image":"http://static.4.mobi/views/images/xnxx.png?x-oss-process=style/120"}]
                
for i in newList:
    key_list = []
    value_list = []
    for key,value in i.items():
        key_list.append(key)
        value_list.append(value) 
   INSERT_STRING = "INSERT INTO `%s` (`%s`) VALUE ('%s')" % (tableName, '`,`'.join(key_list),"', '".join(value_list))