Skip to content
SAPPublic

About

SAP HANA Database Client for Go

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

188 stars

Watchers

14 watching

Forks

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.

cfg := driver.NewConnectorConfig()
cfg.Host, cfg.Username, cfg.Password = "host:port", "user", "password"
connector, err := driver.NewConfigConnector(cfg)
// ... handle err
db := sql.OpenDB(connector)
defer db.Close()
// ...

Full runnable example: Example (source).

Looking for SAP's official HANA client for Go? That's here — this is the community driver.

Install

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

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.

About

SAP HANA Database Client for Go

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

188 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages