这是我的代码:
...
CDN_XL = Database('mssql', CDN_XL_HOST, CDN_XL_PORT, CDN_XL_NAME, CDN_XL_USER, CDN_XL_PASS)
...
def GET(self):
user = USER
if user is None:
raise cherrypy.HTTPError(401, "NOT_AUTHORIZED")
with CDN_XL:
CDN_XL.execute("""Select TrN_DokumentObcy, TrN_NettoR, ToPay, trn_data, trp_termin, data_roz, b_1, b_3, b_4, b_7, b_8, b_9 from(Select DISTINCT TrN_DokumentObcy, TrN_NettoR, SUM(TrP_Pozostaje) as ToPay, DATEADD(day, TrN_Data2, CONVERT(date, '1800-12-28', 120)) as trn_data, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120)) trp_termin, DATEADD(day, TrN_DataRoz, CONVERT(date, '1800-12-28', 120)) as data_roz, DATEADD(day, 1, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_1, DATEADD(day, 3, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_3, DATEADD(day, 4, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_4, DATEADD(day, 7, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_7, DATEADD(day, 8, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_8, DATEADD(day, 9, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_9, DATEADD(day, 10, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_10, DATEADD(day, 14, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_14, DATEADD(day, 15, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_15, DATEADD(day, 22, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_22, DATEADD(day, 23, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_23, DATEADD(day, 40, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_40, DATEADD(day, 41, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_41, DATEADD(day, 70, DATEADD(day, TrP_Termin, CONVERT(date, '1800-12-28', 120))) as b_70 FROM CDN.TraNag, CDN.TraPlat where (TrN_DokumentObcy LIKE 'FS-%' OR TrN_DokumentObcy LIKE 'FSK-%') AND TrN_DokumentObcy NOT LIKE '%/R/%' AND TrN_DokumentObcy NOT LIKE '%/ORG/%' AND TrN_DokumentObcy NOT LIKE '%/CPW/%' AND TrN_DokumentObcy NOT LIKE '%/MC/%' AND TrN_DokumentObcy NOT LIKE '%/INST/%' AND TrN_DokumentObcy <> '' AND TrN_GIDTyp = TrP_GIDTyp and TrN_GIDNumer=trp_gidnumer GROUP BY TrN_DokumentObcy, TrN_Data2, TrN_NettoR, TrN_DataRoz, TrP_Termin) as x Where trn_data >= DATEADD(mm,DATEDIFF(mm,0,GETDATE())-2,0) AND trn_data < DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0);""")
CDN_XL.conn.commit()
logging.debug(CDN_XL.cur.rowcount)
types = CDN_XL.cur.fetchall()
information_json = []
if types is not None and len(types) > 0:
for typ in types:
information_json.append({"numberFactures": str(typ["FactureNumbers"]), "sum": str(typ["SumNetto"])})
output_json = {"payment_list":information_json}
return json.dumps(output_json, ensure_ascii=False)
else:
raise cherrypy.HTTPError(404, "NOT FOUND")
这部分
logging.debug(CDN_XL.cur.rowcount)
返回-1
POSTMAN返回此:
{"payment_list": [{"sum": "None", "numberFactures": "0"}]}
如果我使用其他查询exp。 “ SELECT A,B FROM X”有效,所以为什么在Dbeavear中此查询有效,但是当我想传递给CherryPy并使用POSTMAN时却没有。我真的不明白