# SAP HANA

## Sign up for free cloud trial

* <https://saphanajourney.com/hana-cloud/plans/>
* Go to <https://account.hanatrial.ondemand.com/cockpit>
* Click trial, then "dev" space.
* Then follow <https://saphanajourney.com/hana-cloud/learning-article/how-to-create-your-trial-sap-hana-cloud-instance/>
* Allow access from all IP addresses.
* Need to restart service every day; it's automatically stopped each night.
* Need to create `test` database using database explorer

## Install drivers

* Download SAP HANA installer from <https://www.sap.com/cmp/td/sap-hana-express-edition.html>
* Uncheck virtual machine; check "clients (mac)"
* Untar download
* Untar `hdb_client_mac.tgz`
* `./hdb_inst`

Configure odbc.init: `edit_file("/usr/local/etc/odbcinst.ini")`

```
[SAP HANA]
Description=SAP HANA
Driver=/Applications/sap/hdbclient/libodbcHDB.dylib
```

Check:

```{r}
odbc::odbcListDrivers()
```

## Connect

```{r, eval = FALSE}
con <- DBI::dbConnect(odbc::odbc(),
  driver = "SAP HANA",
  uid = "DBADMIN",
  pwd = "Password12",
  servernode = "a9441502-7166-4a5a-b5d8-23abe3b5009c.hana.trial-us10.hanacloud.ondemand.com:443",
  encrypt="true",
  sslValidateCertificate = "false"
)
class(con)
#> [1] "HDB"
```
