如何在Python中从查询返回所有数据
如何在此查询中从正确数量的行返回所有数据。对于results['results']:print(row)中的row,我将其设置为如何在Python中从查询返回所有数据,python,sql,solarwinds-orion,swissql,Python,Sql,Solarwinds Orion,Swissql,如何在此查询中从正确数量的行返回所有数据。对于results['results']:print(row)中的row,我将其设置为,但我确信这是错误的,因为当我在sql中运行它时,它会返回更多。提前谢谢 results = swis.query("SELECT " "n.Caption AS NodeCaption" ",n.IP_Address AS IPAddress" ",n.NodeID"
,但我确信这是错误的,因为当我在sql中运行它时,它会返回更多。提前谢谢
results = swis.query("SELECT "
"n.Caption AS NodeCaption"
",n.IP_Address AS IPAddress"
",n.NodeID"
",a.ApplicationID "
",n.Uri AS NodeUri "
",n.Uri AS AppUri "
"FROM Orion.Nodes n "
"JOIN Orion.APM.Application a ON n.NodeID = a.NodeID "
"JOIN Orion.APM.ApplicationTemplate at ON a.ApplicationTemplateID = at.ApplicationTemplateID "
"WHERE at.Name IN('Process_Monitor - Dynatrace Linux OneAgent', 'Service_Monitor - Dynatrace"
"OneAgent Service')")
for row in results['results']:
print(row)
查询的结构在select语句之间有太多空格。重写查询后,它就按预期工作了
query = ("SELECT\n"
"n.Caption AS NodeCaption\n"
",n.IP_Address AS IPAddress\n"
",n.NodeID\n"
",a.ApplicationID\n"
",n.Uri AS NodeUri\n"
",a.Uri AS AppUri\n"
"FROM Orion.Nodes n\n"
"JOIN Orion.APM.Application a ON n.NodeID = a.NodeID\n"
"JOIN Orion.APM.ApplicationTemplate at ON a.ApplicationTemplateID = at.ApplicationTemplateID\n"
"WHERE at.Name IN ('Process_Monitor - Dynatrace Linux OneAgent', 'Service_Monitor - Dynatrace OneAgent "
"Service')")