Establishing a session

A 1010data Insights Platform session is an instance of a particular user ID logged into the platform within a certain environment. A session is comprised of a dedicated set of resources that can serve a single request at a time.

A single platform session may have multiple Session objects attached to it. When a user logs into the platform, if no session is active, a new one is created. If a session is currently active for that user, the login type determines if that session is possessed, ended and a new one is started, or fails to connect. Currently, each user ID can only have one platform session associated with it. For more information, see Login types.

In this example, the Session object, testSession is created using py1010.Session. This example uses the with keyword to ensure the session is cleaned up after the query is run. For more information about cleaning up sessions, see Cleaning up a session.

The standard Session object (for a single user) takes four parameters: The Session object also takes a number of optional parameters. For more information, see Optional Parameters.

If you are connecting via a proxy server, your gateway string contains your proxy server address and any credentials. For more information, see Connecting via proxy

import py1010
import sys

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

testSession = py1010.Session(gateway, username, password, py1010.POSSESS)
Note: [USER_NAME] and [PASSWORD] are placeholders for valid Insights Platform user name and password.