go-hdb

module
v1.18.12 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0

README

go-hdb

Go Reference go-version build release license REUSE status

Pure-Go driver for SAP HANA. No cgo, no client library - one static binary. Speaks the HANA SQL Command Network Protocol directly. Built for database/sql, minimal dependencies. Requires Go latest or second latest version.

connector := driver.NewBasicAuthConnector("host:port", "user", "password")
db := sql.OpenDB(connector)

var user string
if err := db.QueryRow("select current_user from dummy").Scan(&user); err != nil {
	// handle error
}

Need the official SAP HANA client Go support (not this driver)? See SAP Help Portal.

Install

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

Quickstart

package main

import (
	"database/sql"
	"log"

	"github.com/SAP/go-hdb/driver"
)

func main() {
	connector := driver.NewBasicAuthConnector("host:port", "user", "password")

	db := sql.OpenDB(connector)
	defer db.Close()

	var user string
	if err := db.QueryRow("select current_user from dummy").Scan(&user); err != nil {
		log.Fatal(err)
	}
	log.Println(user)
}

For HANA Cloud (SNI/TLS), see the cloud connection guide.

Features

Core

  • database/sql compliant, driver.Connector support
  • TLS, PBKDF2 (default) with user/password fallback
  • Auth: LDAP, X.509 client cert, JWT - with refresh callbacks
  • Bulk execution, stored procedures with table output parameters
  • Little-endian (e.g. amd64) and big-endian (e.g. s390x) architecture support

Data

  • UTF-8 to/from CESU-8 for HANA Unicode types
  • HANA decimals as:
    • Go rational numbers via math/big (example).
    • Custom decompose/compose types (example).
  • LOB streaming, scanning rows into structs (driver.StructScanner)
  • LZ4 compression

Observability

  • Driver stats via Connector.NativeDriver().Stats()
  • Per-DB ExStats() (requires driver.OpenDB)
  • Prometheus collectors
  • Per-statement SQL trace via slog

Performance

For diagnosing latency and tuning throughput, see the performance guide.

Documentation

Testing

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

export GOHDBDSN="hdb://user:password@host:port"
go test ./...

Unit-only (no server):

go test --tags unit ./...

License

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. Its design philosophy and development guidelines are documented in AGENTS.md.

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.
compress
Package compress defines the Compressor interface for go-hdb LZ4 wire compression.
Package compress defines the Compressor interface for go-hdb LZ4 wire compression.
dial
Package dial provides types to implement go-hdb custom dialers.
Package dial provides types to implement go-hdb custom dialers.
internal/coltest
Package coltest provides database column definitions used by the driver tests.
Package coltest provides database column definitions used by the driver tests.
internal/profile
Package profile enables profile support.
Package profile enables profile support.
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/trace
Package trace provides helpers to format values for protocol trace output.
Package trace provides helpers to format values for protocol trace output.
internal/unsafe
Package unsafe provides wrapper functions for 'unsafe' type conversions.
Package unsafe provides wrapper functions for 'unsafe' type conversions.
spatial
Package spatial implements geospatial types and functions.
Package spatial implements geospatial 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