mysql库中的数据
import xlrd
import xlwt
from xlutils.copy import copy
import pymysql
database = pymysql.connect("127.0.0.1", "root", "123", "test11", charset='utf8')
cursor = database.cursor()
sql = "SELECT company ,COUNT(company),SUM(weight),SUM(weight*price) FROM data GROUP BY company"
cursor.execute(sql)
result = cursor.fetchall()
# print(result)
for i in result:
if i[0] == '张三粮配':
a_num = i[1]
a_weight = i[2]
a_total_price = i[3]
elif i[0] == '李四粮食':
b_num = i[1]
b_weight = i[2]
b_total_price = i[3]