import sys
sys.path.append("../") # 返回上层路径
from 连接pg import datapg
goods = datapg.query("select distinct goods_name from erp.in_store where in_time between '2021-01-01' and '2022-02-01'")
mms = datapg.query("select distinct(substr(in_time,1,7)) as mm from erp.in_store where in_time between '2021-01-01' and '2022-02-01'")
bar = Bar()
bar.add_xaxis(mms)
for i in goods :#大坑
print(i)
print("SELECT substr(in_time,1,7) as mm ,goods_name,sum(in_count::int) FROM erp.in_store where goods_name='"+str(i)+"' group by substr(in_time,1,7),goods_name ")
incount = datapg.query("SELECT substr(in_time,1,7) as mm ,goods_name,sum(in_count::int) FROM erp.in_store where goods_name='"+i+"' group by substr(in_time,1,7),goods_name ")
bar.add_yaxis(i, incount)
在一次执行SQL获取结果时,老是提示这是一个元组,不是字符串
开始还想的是不是得用repalce把括号和这个逗号去掉
查了下原来要这么写
for (i,) in goods