Quick Start

Get started with xplainpy in 5 minutes.

Installation

pip install xplain

Setup Credentials

Option 1: Environment Variables (Easiest)

export XPLAIN_URL="http://localhost:8080"
export XPLAIN_USER="your-username"
export XPLAIN_PASSWORD="your-password"

Option 2: Config File

Create ~/.xplainpyrc:

{
  "url": "http://localhost:8080",
  "user": "your-username",
  "password": "your-password"
}
chmod 600 ~/.xplainpyrc

First Connection

from xplain import create_session

# Connect to Xplain server
session = create_session()

# Load your data configuration
session.startup("MyDataConfig")

# View the data structure
session.show_tree()

Your First Query

# Build and execute a query
df = (
    session.query_builder("patient_counts")
    .aggregate(object="Patients", type="COUNT")
    .groupby(attribute="Age Group", object="Patients", dimension="Age")
    .execute()
)

print(df)

What’s Next?

Multiple Environments

For managing dev/staging/production credentials:

Config file with profiles:

{
  "profiles": {
    "local": {
      "url": "http://localhost:8080",
      "user": "dev-user",
      "password": "dev-password"
    },
    "production": {
      "url": "https://prod.company.com",
      "user": "prod-user",
      "password": "prod-password"
    }
  },
  "default": "local"
}

Use specific profiles:

from xplain import create_session

# Development
dev = create_session(profile='local')

# Production
prod = create_session(profile='production')

See Authentication & Credential Management for complete details.