go-hdb

module
v1.16.5 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 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, a working Go environment of the latest or second latest Go version is required.

Documentation

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

HANA Cloud Connection

The HANA cloud connection proxy uses SNI, which requires a TLS connection. By default, one can rely on the root certificate set provided by the host, which already comes with the necessary DigiCert certificates (CA, G5). For more information on Go TLS certificate handling, please see https://pkg.go.dev/crypto/tls#Config.

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

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

where:

  • TLSServerName: same as 'host'

Specific Root Certificate

If a specific root certificate (e.g. self-signed) is needed, the TLSRootCAFile DSN parameter must point to the location in the file system where the root certificate file in PEM format is stored.

Tests

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

Set the 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, no CGO.
  • Compliant with the Go database/sql package.
  • UTF-8 to/from CESU-8 encoding for HANA Unicode types.
  • HANA decimals as Go rational numbers via math/big.
  • Large Object streaming.
  • 'Bulk' query execution.
  • Stored Procedures with table output parameters.
  • Parameter free statements and queries via Execer and Queryer interfaces.
  • TLS TCP connections.
  • Little-endian (e.g. amd64) and big-endian (e.g. s390x) architecture support.
  • Driver connector interface.
  • PBKDF2 authentication as default, standard user/password as fallback.
  • LDAP, client certificate (X509) and JWT (JSON Web Token) authentication.
  • Prometheus collectors for driver and extended database statistics.
  • 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.

AI Assistance

This project integrates AI into its development practices. Contributors are expected to review and take ownership of all AI-assisted changes.

Directories

Path Synopsis
cmd
bulkbench command
sniffer command
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 encodings and decodings.
Package encoding implements hdb field type encodings and decodings.
internal/protocol/julian
Package julian provides julian time conversion functions.
Package julian provides 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/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
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