Running a query

Your application should act as an intermediary between your users and the platform to pass in a query and receive the queried data.

Gathering specific sets of data or scoping your data should occur within queries. Typically, the analytical work is done by the Macro Language query specified by the Query object. For more information on writing queries using the Insights Platform Macro Language see the 1010data Reference Manual.

In the example, the new Query object (exampleQuery) is created using the Query method which takes two parameters, the table path and the XML query. As a best practice, longer queries should be stored in a separate file.

You use the run method, which is part of the Query class, to run queries.

import py1010
import sys

gateway = "https://www2.1010data.com/cgi-bin/gw"
tablename = "pub.demo.weather.stations"
username = "[USER_NAME]"
password = "[PASSWORD]"

testSession = py1010.Session(gateway, username, password, py1010.POSSESS)
exampleQuery = testSession.query(tablename, '<sel value="(elev>10)"/>')
exampleQuery.run()
Note: [USER_NAME] and [PASSWORD] are placeholders for valid Insights Platform user name and password.