Configuration Guide
Configure HANA CLI for your development environment.
Connection Configuration
Recommended for CAP projects
If you are working in a SAP CAP project, use the CDS bind approach first. It is the most secure option because credentials are resolved dynamically from your Cloud Foundry or Kubernetes environment instead of being stored locally.
Method 1: CAP CDS bind (Recommended)
When a .cdsrc-private.json file exists (created by cds bind), hana-cli automatically detects it in the current directory or parent directories and reuses those credentials.
# From your CAP project root
cds bind --to <service-instance-name>
# Run any hana-cli command after binding
hana-cli alertsIf you already have a .cdsrc-private.json file, you can skip cds bind and just run hana-cli commands from within the project directory.
For setup details, see Installation Guide.
Method 2: default-env.json
Create a default-env.json file in your working directory manually or via hana-cli connect command.
{
"VCAP_SERVICES": {
"hana": [{
"credentials": {
"host": "hana.example.com",
"port": 30013,
"user": "DBADMIN",
"password": "YourPassword123!",
"database": "HDB"
}
}]
}
}Key Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
host | string | Yes | HANA server hostname or IP |
port | number | Yes | HANA service port (usually 30013) |
user | string | Yes | Database username |
password | string | Yes | Database password |
database | string | No | Database name (default: HDB) |
Method 3: Environment Variables
export HANA_CLI_HOST=your-hana-server.com
export HANA_CLI_PORT=30013
export HANA_CLI_USER=DBADMIN
export HANA_CLI_PASSWORD=yourpassword
export HANA_CLI_DATABASE=HDBMethod 4: Command Line Arguments
Pass connection details with each command:
hana-cli systemInfo \
--host hana.example.com \
--port 30013 \
--user DBADMIN \
--password passwordNamed Profiles
Use named profiles when you want multiple connection presets stored in a configuration file. These are not CDS bindings; they are explicit profile entries you define under profiles in your config.
# Use a specific named profile from your config
hana-cli tables -s SCHEMA --profile productionAdmin Credentials
For admin operations, use separate credentials:
Create default-env-admin.json manually or via hana-cli connect command.
{
"VCAP_SERVICES": {
"hana": [{
"credentials": {
"host": "hana.example.com",
"port": 30013,
"user": "DBADMIN",
"password": "AdminPassword123!"
}
}]
}
}Use with commands:
hana-cli schemaClone --sourceSchema SOURCE --targetSchema TARGET --adminConnection Options
SSL/TLS
{
"VCAP_SERVICES": {
"hana": [{
"credentials": {
"host": "hana.example.com",
"port": 30013,
"user": "DBUSER",
"password": "password",
"encrypt": true,
"sslTrustStore": "/path/to/truststore.pem",
"sslValidateCertificate": true
}
}]
}
}Connection Pooling
# Set pool size
export HANA_CONNECTION_POOL_SIZE=10
# Connection timeout (ms)
export HANA_CONNECTION_TIMEOUT=30000Proxy Configuration
For connections through proxy:
export http_proxy=http://proxy.company.com:8080
export https_proxy=https://proxy.company.com:8080
export no_proxy=localhost,127.0.0.1Or in default-env.json:
{
"VCAP_SERVICES": {
"hana": [{
"credentials": {
"host": "hana.example.com",
"port": 30013,
"user": "DBUSER",
"password": "password",
"proxy": "http://proxy.company.com:8080"
}
}]
}
}Logging Configuration
Log Level
# Available levels: error, warn, info, debug, trace
export HANA_LOG_LEVEL=debug
# Or in command
hana-cli import -n data.csv -t TABLE --debugLog Output
# Log to file
export HANA_LOG_FILE=/path/to/hana-cli.log
# JSON logging
export HANA_LOG_FORMAT=jsonProfile Configuration
Create a .hana-cli-config or hana-cli.config.js file to set defaults for all commands.
This configuration file is automatically loaded at startup and overrides built-in defaults for connection settings, output format, logging, and more.
Configuration file locations (searched in order):
- Current working directory (project-specific):
.hana-cli-configorhana-cli.config.js - User home directory (global):
~/.hana-cli-configor~/hana-cli.config.js
The first configuration file found is used. Project-level config takes priority over global user config.
JSON Configuration (.hana-cli-config)
{
"defaultSchema": "MYSCHEMA",
"defaultProfile": "development",
"outputFormat": "json",
"language": "en",
"logLevel": "info",
"timeout": 30000,
"admin": false,
"debug": false,
"disableVerbose": false
}JavaScript Configuration (hana-cli.config.js)
module.exports = {
defaultSchema: process.env.HANA_SCHEMA || 'MYSCHEMA',
defaultProfile: 'development',
outputFormat: 'json',
language: 'en',
logLevel: 'info',
timeout: 30000,
profiles: {
development: {
host: 'localhost',
port: 30013,
user: 'DBADMIN',
password: 'password'
},
production: {
host: 'prod-hana.company.com',
port: 30013,
user: 'prod_user',
password: process.env.HANA_CLI_PASSWORD
}
}
};Configuration Priority
Configuration priority (highest to lowest):
- Command-line arguments (override everything)
- Project-level config (
.hana-cli-configorhana-cli.config.jsin current directory) - User global config (
~/.hana-cli-configor~/hana-cli.config.js) - Built-in defaults
Example:
# Config file sets defaultSchema to MYSCHEMA
# But this command uses a different schema
hana-cli tables -s OTHERSCHEMAViewing and Managing Configuration
Use the hana-cli config command to view and manage configuration files:
# Display current configuration values
hana-cli config
# Show configuration file paths
hana-cli config --path
# Open config in default editor (creates template if not exists)
hana-cli config -e
# Reset configuration (delete config file)
hana-cli config --reset
# Use global config instead of project config
hana-cli config --globalConfig Command Options
| Option | Short | Description |
|---|---|---|
--edit | -e | Open configuration file in your default editor |
--global | -g | Use global config (home directory) instead of project config |
--path | -p | Show configuration file paths |
--reset | Remove configuration file and reset to defaults |
The config command automatically:
- Displays both project-level and global configuration if they exist
- Shows helpful hints for creating or editing config
- Creates a configuration template when you open a file that doesn't exist yet
Supported Configuration Options
| Option | Type | Description |
|---|---|---|
defaultSchema | string | Default schema for commands (e.g., tables -s SCHEMA) |
defaultProfile | string | Default named profile for commands (e.g., tables --profile production) |
outputFormat | string | Default output format (e.g., json, csv, table) |
language | string | UI language (e.g., en, de, fr) |
logLevel | string | Logging level (error, warn, info, debug, trace) |
timeout | number | Command timeout in milliseconds |
admin | boolean | Default for admin operations |
debug | boolean | Enable debug output by default |
disableVerbose | boolean | Disable verbose output by default |
conn | string | Default connection file path |
profiles | object | Named connection profiles (for --profile option) |
Environment-Specific Configurations
Development
# Enable debug output
export HANA_LOG_LEVEL=debug
# Use local HANA instance
export HANA_CLI_HOST=localhost
export HANA_CLI_PORT=30013Production
# Set production profile
export NODE_ENV=production
# Production HANA instance
export HANA_CLI_HOST=prod-hana.company.com
export HANA_CLI_USER=prod_user
# Enable encryption
export HANA_ENCRYPT=trueTesting
# Use test database
export HANA_CLI_DATABASE=TEST_HDB
# Test credentials
export HANA_CLI_USER=test_user
export HANA_CLI_PASSWORD=test_passwordTroubleshooting Configuration
Cannot Connect
- Verify host and port:
ping hana.example.com - Check credentials are correct
- Ensure database user has required privileges
- Check firewall/network access
SSL Certificate Issues
SSL validation is disabled by default in hana-cli. To enable it with a trusted certificate:
# Connect with a trust store
hana-cli connect -n host:port -u USER -p PASSWORD --trustStore /path/to/cert.pemOr configure in default-env.json:
{
"VCAP_SERVICES": {
"hana": [{
"credentials": {
"host": "hana.example.com",
"port": 30015,
"sslTrustStore": "/path/to/cert.pem",
"sslValidateCertificate": true
}
}]
}
}Proxy Issues
# Test proxy connection
curl -x http://proxy.company.com:8080 https://www.google.com
# Enable proxy debug
export http_proxy_debug=true