go-hdb

module
v1.8.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2024 License: Apache-2.0

README

go-hdb

Go Reference Go Report Card REUSE status

Go-hdb is a native Go (golang) HANA database driver for Go's sql package. It implements the SAP HANA SQL command network protocol.

For the official SAP HANA client Go support (not this database driver) please see SAP Help Portal.

Installation

go get -u github.com/SAP/go-hdb/driver

Building

To build go-hdb you need to have a working Go environment of the latest or second latest Go version.

Documentation

API documentation and documented examples can be found at https://pkg.go.dev/github.com/SAP/go-hdb/driver.

HANA cloud connection

HANA cloud connection proxy is using SNI which does require a TLS connection. To connect successfully you would need a valid root certificate in pem format (please see SAP Help).

The certificate (DigiCertGlobalRootCA.crt.pem) can be downloaded in 'pem-format' from digicert.

Assuming the HANA cloud 'endpoint' is "something.hanacloud.ondemand.com:443". Then the dsn should look as follows:

"hdb://<USER>:<PASSWORD>@something.hanacloud.ondemand.com:443?TLSServerName=something.hanacloud.ondemand.com&TLSRootCAFile=<PATH TO CERTIFICATE>/DigiCertGlobalRootCA.crt.pem"

or

"hdb://<USER>:<PASSWORD>@something.hanacloud.ondemand.com:443?TLSServerName=something.hanacloud.ondemand.com"

with:

  • TLSServerName same as 'host'
  • TLSRootCAFile needs to point to the location in your filesystem where the file DigiCertGlobalRootCA.crt.pem is stored

When omitting the TLSRootCAFile, TLS uses the host's root CA set (for more information please see Config RootCAs.

Tests

To run the driver integration tests a HANA Database server is required. The test user must have privileges to create database schemas.

Set environment variable GOHDBDSN:

#linux example
export GOHDBDSN="hdb://user:password@host:port"
go test

Using the Go build tag 'unit' only the driver unit tests will be executed (no HANA Database server required):

go test --tags unit

Features

  • Native Go implementation (no C libraries, CGO).
  • Go http://golang.org/pkg/database/sql package compliant.
  • Support of database/sql/driver Execer and Queryer interface for parameter free statements and queries.
  • Support of 'bulk' query execution.
  • Support of UTF-8 to / from CESU-8 encodings for HANA Unicode types.
  • Built-in support of HANA decimals as Go rational numbers http://golang.org/pkg/math/big.
  • Support of Large Object streaming.
  • Support of Stored Procedures with table output parameters.
  • Support of TLS TCP connections.
  • Support of little-endian (e.g. amd64) and big-endian architectures (e.g. s390x).
  • Support of driver connector.
  • Support of PBKDF2 authentication as default and standard user / password as fallback.
  • Support of client certificate (X509) and JWT (JSON Web Token) authentication.
  • Prometheus collectors for driver and extended database statistics.
  • Support of scanning database rows into go structs.

Dependencies

Licensing

SAP SE or an SAP affiliate company and go-hdb contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.

Directories

Path Synopsis
cmd
Package driver is a native Go SAP HANA driver implementation for the database/sql package.
Package driver is a native Go SAP HANA driver implementation for the database/sql package.
dial
Package dial provides types to implement go-hdb custom dialers.
Package dial provides types to implement go-hdb custom dialers.
internal/protocol
Package protocol implements the hdb command network protocol.
Package protocol implements the hdb command network protocol.
internal/protocol/auth
Package auth provides authentication methods.
Package auth provides authentication methods.
internal/protocol/encoding
Package encoding implements hdb field type en,- and decodings.
Package encoding implements hdb field type en,- and decodings.
internal/protocol/julian
Package julian provided julian time conversion functions.
Package julian provided julian time conversion functions.
internal/protocol/levenshtein
Package levenshtein includes the levenshtein distance algorithm plus additional helper functions.
Package levenshtein includes the levenshtein distance algorithm plus additional helper functions.
internal/rand/alphanum
Package alphanum implements functions for randomized alphanum content.
Package alphanum implements functions for randomized alphanum content.
internal/reflect
Package reflect provides a compatibility layer until g1.21 is out of maintenance.
Package reflect provides a compatibility layer until g1.21 is out of maintenance.
internal/types
Package types provides database types.
Package types provides database types.
internal/unsafe
Package unsafe provides wrapper functions for 'unsafe' type conversions.
Package unsafe provides wrapper functions for 'unsafe' type conversions.
spatial
Package spatial implements geo spatial types and functions.
Package spatial implements geo spatial types and functions.
unicode/cesu8
Package cesu8 implements functions and constants to support text encoded in CESU-8.
Package cesu8 implements functions and constants to support text encoded in CESU-8.
prometheus module
collectors
Package collectors provides prometheus collectors for driver and extended database statistics.
Package collectors provides prometheus collectors for driver and extended database statistics.
Package sqlscript provides functions to scan HDBSQL scripts with the help of bufio.Scanner.
Package sqlscript provides functions to scan HDBSQL scripts with the help of bufio.Scanner.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL