#!/usr/bin/env python #-*-coding:utf-8-*- import pymysql import json import collections conn = pymysql.connect(host='xxx.xxx.xxx.xxx', user='xxx', passwd='xxx', port=3308 , charset='xxx', database='xxx', cursorclass = pymysql.cursors.DictCursor) sql=…