Entry Points
Recommended entry point
Use xplain.connect() to create an xplain.XplainSession and
optionally load a startup configuration. The context manager closes the
session when the block exits. Credentials can come from a profile or the
XPLAIN_* environment variables; see Authentication & Credential Management.
import xplain
with xplain.connect(profile='production', startup='TestSet1') as xp:
xp.show_tree()
Pass startup explicitly: connect does not automatically load a
profile’s startup setting. Object and startup names are dataset-specific.
See Quick Start for a first query and pitfalls for important
selection and counting semantics.
Other entry points
The following forms also return an xplain.XplainSession and allow
loading a startup later with xp.startup(...):
from xplain import create_session
# 1. Top-level helper (uses default profile from ~/.xplainpyrc)
xp = create_session()
# …or pick a named profile
xp = create_session(profile='production')
from xplain import XplainSession
# 2. Classmethod form — equivalent to the call above
xp = XplainSession.from_profile('production')
Both ultimately wrap the same underlying Xsession with the same
credential resolution rules (see Authentication & Credential Management). The result is
an XplainSession with the 8 namespaces ready to use:
xp.startup('TestSet1')
df = xp.query.attribute('Patients', 'Gender', 'Gender')
xp.select.values('Patients', 'Gender', ['Male'])
Attaching to an existing server session by ID:
xp = XplainSession.from_session_id(
url='https://xoe.example.com',
session_id='CED14155E7A90C9376749487A6B52C24',
)
Note
xplain.config.create_session() previously returned the legacy
xplain.Xsession. It now returns XplainSession.
Existing code that calls Xsession methods on the result
(session.startup, session.execute_query, session.run …)
continues to work — XplainSession delegates all public
Xsession methods. Only isinstance(session, Xsession) checks need
updating.