Python-将查询的输出定义为变量

时间:2018-12-03 10:36:57

标签: sql python-3.x amazon-redshift

我试图将SQL查询的输出调用为变量,如下所示:

cur = conn.cursor()
cur.execute("""select store_name,DATE_TRUNC('month',bill_date)as month,count(*) from sales""")
monthly_report = dwh_cur.fetchall()

此文件的输出如下:

store_name,month,count
store_a,jan,100
store_a,feb,200
store_a,mar,230

我正试图将月份传递给变量(var1),然后再计入另一个变量(var2)

任何人都可以建议我如何相应地定义它。谢谢

0 个答案:

没有答案