Skip to content

Data lake Client tutorial update #23357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tutorials/hana-clients-golang/add-bin-to-path.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 12 additions & 19 deletions tutorials/hana-clients-golang/hana-clients-golang.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Go is an open-source programming language developed by Google to increase produc
---

### Install Go

The first step is to check if Go is installed, and if so, which version. To do so, enter the following command:

```Shell
Expand Down Expand Up @@ -57,6 +56,14 @@ The SAP HANA Client interface for Go, like the other SAP HANA client interfaces,

If command prompt isn't showing you the installed version after running the version check command, manually add the bin folder to your path by setting it in your environment variables.

>On Windows, search **Edit the System Environment Variables** and click on **Environment Variables...**.
>
![Edit Environment Variables](editEnvironmentVariables.png)

Look for the `Path` environment variable and double click to edit. Select **Browse** and manually browse through your File Explorer to find the bin folder.

![Add bin to path](add-bin-to-path.png)

On Linux, install the System GNU C compiler for your version of Linux. Note that if you are using openSUSE, minGW is included in the installation for Go through YaST.

![gcc 64-bit](gccLinux.png)
Expand All @@ -71,38 +78,24 @@ The SAP HANA Client interface for Go, like the other SAP HANA client interfaces,

GOPATH is set to a location such as `C:\Users\user\go` or `$HOME/go` and defines the root of your workspace which stores your codebase.

3. Set the required environment variables.

On Windows, search **Edit the System Environment Variables** and click on **Environment Variables...**.

>Optionally, you can also use the **SETX** command in command prompt to set a Windows environment variable. For example, `SETX CGO_LDFLAGS C:\SAP\hdbclient\libdbcapiHDB.dll`. Note that this will set a user variable, not a system variable.

![Edit Environment Variables](editEnvironmentVariables.png)

On Linux, open the `.bash_profile`.

```Shell (Linux or Mac)
pico ~/.bash_profile
```

4. Set the `CGO_LDFLAGS` environment variable to point to the location of the `libdbcapiHDB` library as shown below and set the `LD_LIBRARY_PATH` if needed.
3. Set the `CGO_LDFLAGS` environment variable to point to the location of the `libdbcapiHDB` library as shown below and set the `LD_LIBRARY_PATH` if needed.

On Windows, add the **NEW** System Variable. Set the variable name to **`CGO_LDFLAGS`** and the variable value to the location of `dbcapi` library: `C:\SAP\hdbclient\libdbcapiHDB.dll`
On Windows, add a **NEW** variable. Set the variable name to **`CGO_LDFLAGS`** and the variable value to the location of `dbcapi` library: `C:\SAP\hdbclient\libdbcapiHDB.dll`

![Set Environment Variables](setEnvVar.png)

Ensure that the `hdbclient` folder is set in your **Path** environment variable. You can set this path by clicking on **New** and browsing for your `hdbclient` folder.

![hdbclient path env variable](hdbclient-path.png)

On Linux, add the following lines to the `bash_profile`.
On Linux, add the following lines to the `.bash_profile`.

```Shell (Linux or Mac)
export CGO_LDFLAGS=$HOME/sap/hdbclient/libdbcapiHDB.so
export LD_LIBRARY_PATH=$HOME/sap/hdbclient
```

5. Go to the driver folder and create a go module.
4. Go to the driver folder and create a go module.

```Shell (Windows)
cd C:\SAP\hdbclient\golang\src\SAP\go-hdb\driver
Expand Down
Binary file modified tutorials/hana-clients-golang/winLibsMinGW.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tutorials/hana-clients-jdbc/hana-clients-jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ primary_tag: software-product>sap-hana-cloud

Ensure that you have a Java Development Kit (JDK) installed and ensure that it is accessible from your path. Details on supported versions can be found at SAP Note [3165810 - SAP HANA Client Supported Platforms](https://launchpad.support.sap.com/#/notes/3165810).

An OpenJDK from SAP is available at [SapMachine](https://sap.github.io/SapMachine/#download)
An OpenJDK from SAP is available at [SapMachine](https://sap.github.io/SapMachine/#download).

To verify that the JDK is correctly set up, run the following:

Expand Down
6 changes: 2 additions & 4 deletions tutorials/hana-clients-python/hana-clients-python.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ primary_tag: software-product>sap-hana-cloud
- How to create and debug a Python application that queries a SAP HANA database

## Intro
In the 2023 Stack Overflow's annual developer survey, Python ranked 3rd in the [Most popular technologies](https://survey.stackoverflow.co/2023/#most-popular-technologies-language) section. For further information on Python, see [Introduction to Python 3](https://realpython.com/python-introduction/).
In the 2023 Stack Overflow's annual developer survey, Python ranked 3rd in the [Most popular technologies](https://survey.stackoverflow.co/2023/#most-popular-technologies-language) section. For further information on Python, see [Introduction to Python 3](https://realpython.com/python-introduction/) or [The Python Tutorial](https://docs.python.org/3/tutorial/).

The following steps create a simple Python app that can connect to and query an SAP HANA database.

Expand Down Expand Up @@ -233,11 +233,9 @@ The code in `pythonQuery.py` uses [PEP 249 -- Python Database API Specification]


### Debug the application


Visual Studio Code provides plugins for Python and can be used to debug an application.

1. Open Visual Studio Code. If needed, download the application [here](https://code.visualstudio.com/Download).
1. If you have not already done so, download [Visual Studio Code](https://code.visualstudio.com/Download).

2. If you have not already done so, add the tutorial folder to the workspace by choosing **File | Add Folder to Workspace**, and then add the `HANAClientsTutorial` folder.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ If you wish to access alerts and metrics for multiple instances with one API cal

4. Create a new file named AlertsAndMetrics2.http file with the contents below. Highlighted values are to be updated with details from the service binding created in the previous step and optionally an instance ID.

```HTTP[6, 9, 12, 15, 17]
```HTTP[6, 9, 12, 15, 18]
#REST Client variables -------------------

@oauth = oauth/token?grant_type=client_credentials
Expand Down
2 changes: 1 addition & 1 deletion tutorials/hana-cloud-alerts/hana-cloud-alerts.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Alerts can inform you of potential issues before they occur, such as when the nu

You can find details of any raised alerts through the alerts app in SAP HANA Cloud Central or by using the [REST API](hana-cloud-alerts-rest-api) (SAP HANA database). This is known as a pull approach.

Alternatively, alert details can be pushed to several configured channels such as email, Slack, or Microsoft Teams.
Alternatively, alert details can be pushed to several configured channels such as email, Slack, or Microsoft Teams. A list of built-in events can be found at [SAP HANA Cloud Service Database Events](https://help.sap.com/docs/alert-notification/sap-alert-notification-for-sap-btp/sap-hana-cloud-service-database-events).

> Access help from the SAP community or provide feedback on this tutorial by navigating to the "Feedback" link located on the top right of this page.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ The subaccount ID can be obtained on the BTP Cockpit Overview page for the subac
![subaccount ID](subaccount-id.png)

#### Create an instance
In order to create an instance, a JSON describing the instance is required and a plan ID.
In order to create an instance, JSON describing the instance is required as well as a plan ID.

* Create a JSON file named **create.json** that specifies the parameters of the instance to be created. The JSON can be generated in the SAP HANA Cloud Central instance creation wizard or can come from an existing instance.

Expand Down Expand Up @@ -640,7 +640,7 @@ Log on to Cloud Foundry using an API endpoint.
![cf login](cf-login.png)

#### Create an instance
In order to create an instance, a JSON describing the instance is required as is a service offering name and plan.
In order to create an instance, JSON describing the instance is required, as well as a service offering name and plan.

* Create a JSON file named **create.json**.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ primary_tag: software-product-function>sap-hana-cloud--data-lake
- How to create and debug a .NET application that queries a data lake Relational Engine

## Intro
[.NET](https://en.wikipedia.org/wiki/.NET_Core) is a free and open source software framework for Microsoft Windows, Linux and Mac operating systems and is the successor to the .NET Framework. .NET was previously known as .NET Core.
[.NET](https://en.wikipedia.org/wiki/.NET_Core) is a free and open-source software framework for Microsoft Windows, Linux and Mac operating systems and is the successor to the .NET Framework. .NET was previously known as .NET Core.

---

Expand Down
Binary file modified tutorials/hana-cloud-dl-clients-dot-net/install.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tutorials/hana-cloud-dl-clients-golang/add-bin-to-path.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tutorials/hana-cloud-dl-clients-golang/createModule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ primary_tag: software-product-function>sap-hana-cloud--data-lake
- How to install Go
- How to create and debug a Go application that queries a data lake Relational Engine

## Intro
Go is an open source programming language developed by Google to increase productivity among programmers. For more information, see the [Go Documentation](https://golang.org/doc/).
## Intro
Go is an open-source programming language developed by Google to increase productivity among programmers. For more information, see the [Go Documentation](https://golang.org/doc/).

---

Expand All @@ -31,7 +31,7 @@ go version

![go version linux](version2.png)

If Go is installed, then it will return the currently installed version, such as 1.20.4
If Go is installed, then it will return the currently installed version, such as 1.21.5

If it is not installed, download it from [Download Go](https://golang.org/dl/), run the installer, follow the provided instructions, and ensure that Go is in your path.

Expand All @@ -43,7 +43,7 @@ On Linux, follow the instructions for the appropriate Linux version: [Installing

The data lake Relational Engine Client interface for Go, like the other data lake Relational Engine client interfaces (except JDBC), makes use of a C library named SQLDBC.

The Go driver loads the SQLDBC library named `libdbcapiHDB` using [`cgo`](https://golang.org/cmd/cgo/). For further information on the following steps, consult [Build the Go Driver](https://help.sap.com/docs/SAP_HANA_DATA_LAKE/a895964984f210158925ce02750eb580/0f3109338be048e187caa9646199e3db.html?state=DRAFT) in the SAP HANA Cloud, Data Lake Client Interfaces Reference Guide. In order to use the Go Driver, a 64-bit `gcc` compiler is required.
The Go driver loads the SQLDBC library named `libdbcapiHDB` using [cgo](https://golang.org/cmd/cgo/). For further information on the following steps, consult [Build the Go Driver](https://help.sap.com/docs/SAP_HANA_DATA_LAKE/a895964984f210158925ce02750eb580/0f3109338be048e187caa9646199e3db.html?state=DRAFT) in the SAP HANA Cloud, Data Lake Client Interfaces Reference Guide. In order to use the Go Driver, a 64-bit `gcc` compiler is required.

1. To check if a 64-bit `gcc` compiler is installed, run the following command:

Expand All @@ -61,7 +61,7 @@ The Go driver loads the SQLDBC library named `libdbcapiHDB` using [`cgo`](https
>
![Edit Environment Variables](editEnvironmentVariables.png)

Look for the `Path` environment variable and double click to edit. Select **Browse** and manually browse through your File Explorer to find the bin folder
Look for the `Path` environment variable and double click to edit. Select **Browse** and manually browse through your File Explorer to find the bin folder.

![Add bin to path](add-bin-to-path.png)

Expand All @@ -79,42 +79,33 @@ The Go driver loads the SQLDBC library named `libdbcapiHDB` using [`cgo`](https

GOPATH is set to a location such as `C:\Users\user\go` or `$HOME/go` and defines the root of your workspace which stores your codebase.

3. Set the required environment variables.

>On Windows, navigate to the start menu and search for **system** environment variables.
Optionally, you can also use the **SETX** command in command prompt to set a Windows environment variable. For example, `SETX CGO_LDFLAGS C:\SAP\hdlclient\IQ-17_1\Bin64\dbcapi.dll`. Note that this will set a user variable, not a system variable.
3. Set the `CGO_LDFLAGS` environment variable to point to the location of the HDLRE client library as shown below and set the `LD_LIBRARY_PATH` if needed.


On Linux, open the .bash_profile
On Windows, add a **NEW** variable. Set the variable name to **CGO_LDFLAGS** and the value as the location of `dbcapi` library: `C:\SAP\dlclient\IQ-17_1\Bin64\dbcapi.dll`

```Shell (Linux)
pico ~/.bash_profile
```
![Set Environment Variables](setEnvVar.png)

4. Set the `CGO_LDFLAGS` environment variable to point to the location of the HDLRE client library as shown below, and set the `LD_LIBRARY_PATH` if needed.
>It is also possible on Microsoft Windows to set this using the SETX command from a shell.

On Windows, add a **NEW** System Variable. Set the variable name to **CGO_LDFLAGS** and the value as the location of `dbcapi` library: `C:\SAP\hdlclient\IQ-17_1\Bin64\dbcapi.dll`

![Set Environment Variables](setEnvVar.png)

On Linux, add the following lines to the bash_profile.
On Linux, add the following lines to the `.bash_profile`.

```Shell (Linux)
export CGO_LDFLAGS=$HOME/sap/dlclient/IQ-17_1/lib64/libdbcapi_r.so
export LD_LIBRARY_PATH=$HOME/sap/dlclient/IQ-17_1/lib64
```
![.bash_profile contents](bashProfileAfterCGO.png)

5. Navigate to the driver folder and create a Go module.
4. Navigate to the driver folder and create a Go module.

```Shell (Windows)
cd C:\SAP\hdlclient\IQ-17_1\SDK\golang\SAP\go-hdlre\driver
cd %IQDIR17%\sdk\golang\SAP\go-hdlre\driver
go mod init "SAP/go-hdlre/driver"
go mod tidy
```

```Shell (Linux)
cd ~/sap/dlclient/IQ-17_1/sdk/golang-hdlre/src/SAP/go-hdlre/driver
cd $IQDIR17/sdk/golang-hdlre/src/SAP/go-hdlre/driver
go mod init "SAP/go-hdlre/driver"
go mod tidy
```
Expand All @@ -135,7 +126,8 @@ The Go driver loads the SQLDBC library named `libdbcapiHDB` using [`cgo`](https
cd ~/DataLakeClientsTutorial/go
pico goQuery.go
```
2. Add the code below to `goQuery.go`:

2. Add the code below to `goQuery.go` and then modify the connectString variable.

```Go Code
package main
Expand All @@ -150,7 +142,7 @@ The Go driver loads the SQLDBC library named `libdbcapiHDB` using [`cgo`](https

func main() {
//specify the connection parameters
connectString := "hdlre://User1:[email protected]ca10.hanacloud.ondemand.com:443?enc='TLS{tls_type=rsa;direct=yes}'"
connectString := "hdlre://User1:[email protected]xxxx.hanacloud.ondemand.com:443?enc='TLS{tls_type=rsa;direct=yes}'"

fmt.Println("Connect String is " + connectString)

Expand Down Expand Up @@ -207,7 +199,7 @@ The Go driver loads the SQLDBC library named `libdbcapiHDB` using [`cgo`](https
>Make any necessary changes to ensure the path to the driver folder is correct.

```Code (Windows)
replace SAP/go-hdlre/driver v0.1.0 => C:\SAP\hdlclient\IQ-17_1\SDK\golang\SAP\go-hdlre\driver
replace SAP/go-hdlre/driver v0.1.0 => C:\SAP\dlclient\IQ-17_1\SDK\golang\SAP\go-hdlre\driver
require SAP/go-hdlre/driver v0.1.0
```

Expand All @@ -230,8 +222,6 @@ For more information on the API's used, consult the SAP HANA Cloud, data lake co


### Debug the application


Visual Studio Code provides plugins for Go and can be used to debug an application.

1. If you have not already done so, download [Visual Studio Code](https://code.visualstudio.com/Download).
Expand Down Expand Up @@ -264,7 +254,7 @@ Visual Studio Code provides plugins for Go and can be used to debug an applicati

### Knowledge check

Congratulations! You have now created and debugged a Go application that connects to and queries an data lake Relational Engine.
Congratulations! You have now created and debugged a Go application that connects to and queries a data lake Relational Engine.



Expand Down
Binary file modified tutorials/hana-cloud-dl-clients-golang/results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tutorials/hana-cloud-dl-clients-golang/setEnvVar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified tutorials/hana-cloud-dl-clients-golang/version2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tutorials/hana-cloud-dl-clients-golang/winLibsMinGW.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading