#! /usr/bin/env python
# coding=utf-8
import json
import urllib
import pymysql
con = pymysql.connect(host="10.32.81.16", user="root", passwd="abc123.com", db="fncoperation", charset='utf8',port=5366)
f = open(r'D:	estfile.txt','rb')
w = f.read()
f.close()
jsonDic = eval(w)
locations = json.loads(jsonDic)
for location in locations:
    appid = location["time-series-group"]["appId"]
    errorcount = location["data-points"]["total"]


    cursor = con.cursor()
    sql ="insert into app_error_01 (appid,errorcount) values ("+appid+","+errorcount+")"
    print  sql
    cursor.execute(sql)
    con.commit()
    cursor=cursor.close()
con.close()
原文地址:https://www.cnblogs.com/yspass/p/7490459.html