#! /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:\test\file.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()

 

posted @ 2017-09-07 16:30  zhang.ning  阅读(282)  评论(0编辑  收藏  举报