Config
Configuration management for kxi.
The primary entrypoint is the settings singleton, which provides access
to the active connection profile, environment overrides, and credentials.
Example
Read the current connection URL and switch profiles:
from kxi.config import settings
# Read the active profile's connection URL
host = settings.runtime.hostname
# Switch to a named profile
settings.profile = "production"
host = settings.runtime.hostname
# Reload settings after editing config files on disk
settings.reload()
Classes:
- BaseConfig – File path settings for kxi configuration.
- KXIConfig – Full kxi configuration including all named profiles.
- KXIProfile – Connection profile settings for kdb Insights Enterprise.
BaseConfig¶
Bases: BaseSettings
File path settings for kxi configuration.
All paths default to ~/.insights/ but can be overridden via environment variables.
The root directory itself is controlled by the INSIGHTS_CONFIG_HOME environment variable.
Attributes:
- config_toml_path (
Path) – Main TOML config file. Env:KXI_CONFIG_PATH. Default:~/.insights/config.toml. - pakx_config_path (
Path) – pakx config file. Env:PAKX_CONFIG_PATH. Default:~/.insights/pakx-config. - pakx_sources_path (
Path) – pakx sources file. Env:PAKX_SOURCES_PATH. Default:~/.insights/pakx.sources. - credentials_path (
Path) – Credentials TOML file. Env:CREDENTIALS_PATH. Default:~/.insights/credentials.toml. - config_ini_path (
Path) – Legacy ini-format config (versions 1.11 and below). Default:~/.insights/cli-config.
Functions:
- set_root – Set the root path for the config.
set_root¶
set_root(root)
Set the root path for the config.
KXIConfig¶
Bases: KXBaseConfig
Full kxi configuration including all named profiles.
Loaded from ~/.insights/config.toml and the legacy ~/.insights/cli-config.
Manages profile selection and persistence. Access via settings.kxi.
Attributes:
- profiles (
dict[str, KXIProfile]) – All configured profiles keyed by profile name. - current_profile (
str) – Name of the active profile. Default:"default". Env:KXI_PROFILE.
Example
from kxi.config import settings
# List all configured profiles
print(list(settings.kxi.profiles.keys()))
# Save config changes to disk
settings.kxi.save()
Functions:
- get_current – Get the current profile.
- save – Save the config to disk.
- save_ini – Save the config in ini format to disk.
get_current¶
get_current()
Get the current profile.
save¶
save()
Save the config to disk.
save_ini¶
save_ini()
Save the config in ini format to disk.
KXIProfile¶
Bases: KXBaseConfig
Connection profile settings for kdb Insights Enterprise.
Values are loaded from the active config file profile and then overridden
by matching environment variables. Access via settings.runtime to get
the fully merged result.
Attributes:
- hostname (
str | None) – Connection URL. Env:INSIGHTS_URL. - namespace (
str | None) – Kubernetes namespace of the deployment. - keycloak_url (
str | None) – Keycloak authentication URL. Env:KXI_KEYCLOAK_SVC_URL. - realm (
str) – Keycloak realm name. Default:"insights". Env:INSIGHTS_REALM. - auth_enabled (
bool) – Enable Keycloak authentication. Default:True. Env:KXI_AUTH_ENABLED. - auth_serviceaccount_id (
str) – OAuth2 client ID. Env:INSIGHTS_CLIENT_ID. - auth_serviceaccount_secret (
str) – OAuth2 client secret. Env:INSIGHTS_CLIENT_SECRET. - grant (
GrantType | None) – OAuth2 grant type (userorserviceaccount). - use_credentials (
bool) – Persist credentials to disk. Default:True.