This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

How do I use multiple parameter requests with orionsdk-python?

Hello. I can't figure out how to use multiple parameters when running a query with the orionsdk-python. Can someone show me the correct syntax? Thanks.

swis.query('SELECT NodeID, Caption FROM Orion.Nodes WHERE Caption LIKE @capt', capt=['SWITCH%', 'ROUTER%'])

  • The LIKE operator only supports a single pattern. To match against two patterns, you would need something like this:

    swis.query('SELECT NodeID, Caption FROM Orion.Nodes WHERE Caption LIKE @capt1 OR Caption LIKE @capt2', capt1='SWITCH%', capt2='ROUTER%')

    Unfortunately this does not easily scale for an arbitrary number of patterns. If the number of patterns to match against is variable, you would need to build up the query programmatically with another OR clause for each pattern.

  • Thanks. Do you know what the syntax would be for a WHERE x IN?

    Here's an example:

    swis.query('SELECT Uri FROM Orion.Nodes WHERE IPAddress IN @ip_addr, ip_addr = [x, y, z])

  • I haven't tested that exact query, but the syntax looks right to me. Does it work?

  • It's really close.  It needs a closing single quote before the comma, and the x, y, z IP address need to be enclosed in quotes:

    swis.query('SELECT Uri FROM Orion.Nodes WHERE IPAddress IN @ip_addr', ip_addr = ['x', 'y', 'z'])

    And, of course, they need to be actual IP addresses.