即时通讯使用可以通过JSON发送sql查询的SDK,但是我收到错误:
File "/usr/lib/python2.7/site-packages/requests/models.py", line 893, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: mismatched input 'ON' expecting 'EOF' for url: https://solarwinds-orion:17778/SolarWinds/InformationService/v3/Json/Query
这是我使用的代码:
swis = SwisClient(hostname, username, password, verify=v_path)
query = """
SELECT NodeID,NodeName,IPAddress,IP,IP_Address,NodeIPAddresses
FROM Orion.Nodes ON
inner join Orion.NodesCustomProperties CP
on ON.NodeID = CP.NodeID
WHERE CP.smartnet = 1
"""
results = swis.query(query)
这是模式的链接
customproperties - http://solarwinds.github.io/OrionSDK/schema/Orion.NodesCustomProperties.html 节点 - http://solarwinds.github.io/OrionSDK/schema/Orion.Nodes.html
从我在内部联接上搜索到的查询应该没问题?
答案 0 :(得分:1)
将您的表别名从ON
更改为其他内容,您应该没问题:
SELECT NodeID -- You should also be using the appropriate table alias
,NodeName -- for each of these columns.
,IPAddress
,IP
,IP_Address
,NodeIPAddresses
FROM Orion.Nodes N
inner join Orion.NodesCustomProperties CP
on N.NodeID = CP.NodeID
WHERE CP.smartnet = 1
这是一个错误,因为on
是一个保留关键字,如select
或and
,它对sql编译器有重要意义。