> For the complete documentation index, see [llms.txt](https://docs.lumi-ai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lumi-ai.com/product-features/source-system-integrations/sap-hana.md).

# SAP HANA

Lumi currently supports S4 SAP HANA and the following document covers the usage of the database within the application.

## Supported Methods

Means for Lumi to connect to the client to implement the services required:

* [ ] **Direct**

  *The default / typical connection option. Interfaces directly with the target system over the Internet with no mediation. Suitable for most cloud-hosted scenarios or public-facing resources. See* [*Network Configuration*](/using-lumi/network-configuration.md) *for more details.*
* [x] **Gateway**\
  \&#xNAN;*An alternative connection method leveraging a Lumi AI Data Gateway. This uses Lumi AI's purpose-built connection agent to mediate communications. Ideal for restricting access to systems within a protected network. For more information, see* [*Data Gateway*](/product-features/data-gateway.md)*.*

{% hint style="info" %}
SAP HANA requires the Data Gateway — a direct connection is not supported. See [SAP HANA Client Installation](#sap-hana-client-installation).
{% endhint %}

## Supported Limits

The following are limitations that can be set to fine tune the agents' actions:

* [ ] **Cost Limit**\
  \&#xNAN;*Before running a query, if the system supports it, the system-specific compute cost (or surrogate) estimate will be processed and compared to an organization-level/admin-set cost limit for systems of this type (if configured/set). If exceeded, the query will not run (and either the workflow will attempt an optimization or the user will be notified).*
* [ ] **Duration Limit**\
  \&#xNAN;*An alternative to cost, queries will be stopped the system supports a duration/timeout limit and one is set/configured at the organization level (across systems).*

## Available Parameters

These properties are the essential source system connection properties that all queries are directed towards.

*\* Required parameters*

<details>

<summary>Host*</summary>

Domain or IP of the database to allow a connection to Lumi AI.

:thumbsup: **Valid Examples**

* Domain name: *docs.lumi-ai.com*
* IPv4: *55.88.92.101*

:thumbsdown: **Invalid Examples**

* IPv4 with alphanumeric characters: *123.abc.def.456*
* Incomplete domain name resolutions: *lumi-ai.com*

</details>

<details>

<summary>Port*</summary>

Access port to allow for connections to the database.

:thumbsup: **Valid Examples**

* Default HANA SQL Port: *30015*
* SQL Interface Over HTTPS: *30013*
* XS Engine HTTP Port: *8000*
* XS Engine HTTPS Port: *44300*

:thumbsdown: **Invalid Examples**

* Known Port Numbers (0-1023): *80*

</details>

<details>

<summary>Username*</summary>

Username of the generated database user which will be used for interactions and transactions.

:thumbsup: **Valid Examples**

* Uses alphanumeric characters : *lumi1*
* Utilizing underscore (\_) in place of spaces: *user\_number*

:thumbsdown: **Invalid Examples**

* Starting with a number: *1lumi*
* Utilizing spaces: *user name*
* Using invalid characters unquoted: *user#1*

</details>

<details>

<summary>Password*</summary>

Password of the generated database user which will be used for interactions and transactions.

</details>

<details>

<summary>Database*</summary>

Literal database name that will be used for transactions within the agents.

**Special Considerations**

* If case sensitivity is required, utilize double quotes for database name; ex. "New\_database"

:thumbsup: **Valid Examples**

* Uses alphanumeric characters: *lumi1*
* Utilizing underscore (\_) in place of spaces: *new\_database*

:thumbsdown: **Invalid Examples**

* Starting with a number: *1lumi*
* Utilizing spaces: *user name*
* Using reserved words unquoted: *select*
* Has invalid special character unquoted: *lumi#2*

</details>

## SAP HANA Client Installation

Connections to SAP HANA are made through the SAP HANA client (`hdbcli`), which SAP licenses under its own terms. Lumi does not distribute the client with the Data Gateway, so it has to be installed once on the machine running the gateway, using your organization's existing SAP HANA entitlement.

{% hint style="info" %}
This step applies only to SAP HANA. No other source system requires a separately installed driver.
{% endhint %}

### 1. Install the client

On the machine running the Data Gateway, install the client into a directory of your choosing:

```
pip install --target /opt/sap/hana-client hdbcli
```

Any location readable by the account the gateway runs as will do. The client is published for all common platforms; make sure you install the build matching the gateway host's operating system and CPU architecture.

### 2. Point the gateway at it

Give the gateway the directory containing the client, using any of the standard configuration channels:

* Command line: `--hana-client-path /opt/sap/hana-client`
* Environment variable: `LUMI_AI_DATA_GATEWAY_HANA_CLIENT_PATH=/opt/sap/hana-client`
* `config.yaml`: `hana_client_path: /opt/sap/hana-client`

Restart the gateway after setting it. On startup the gateway logs the path it added, so the log line confirms the setting was picked up.

{% hint style="warning" %}
If the client is missing when a SAP HANA query runs, the query fails with a driver error naming this setting. Other source systems are unaffected -- the gateway starts and serves them normally whether or not the SAP HANA client is installed.
{% endhint %}

## System Permissions & Configuration

Provided user must have the following:

* [x] If applicable CREATE a user
* [x] Grant the user SELECT privileges on the schema and tables:
  * [x] `GRANT SELECT ON SCHEMA my_schema TO service_user;`\
    `GRANT SELECT ON TABLE my_schema.my_table TO service_user;`

For configurations:

* [x] Ensure the server is allowing connections from the Lumi gateway or server via the firewall

## Special Notes

* Special characters and case sensitivity can be utilized in database names and usernames via encasing the name in double quotes (" "), but is not recommended

## Common Issues

* Ensure the SAP HANA client is installed on the gateway host and `hana_client_path` points at it (see [SAP HANA Client Installation](#sap-hana-client-installation))
* Ensure the firewall settings allow for a connection to the database
* Ensure the username, password, and database values are explicitly provided
