百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

go-hdb

> 数据库
开源

适用于 Go 的 SAP HANA 数据库客户端

188 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

适用于 Go 的 SAP HANA 数据库客户端

go-hdb

Go-hdb is a native Go (Golang) HANA database driver for Go's database/sql package. It implements the "SAP HANA SQL Command Network Protocol" directly, so it is pure Go with no cgo and no HANA client library dependency — a single statically linked binary, cross-compilable, with driver upgrades decoupled from the database version.

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

Features

  • 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 (example).
    • custom decimal types via the database/sql decimal decompose / compose interfaces (example).
  • 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.
  • LZ4 compression support.

Installation

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

Quickstart

go
package main

import (
	"database/sql"
	"fmt"

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

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

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

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

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 .

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://:@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:

bash
#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

CPU Profiling

Integration tests include network I/O which dominates wall time and obscures driver CPU cost. To profile only the driver code, collect a CPU profile and then filter out database-tagged samples with tagignore=db:

go test -v -test.cpuprofile cpu.out
go tool pprof cpu.out
(pprof) tagignore=db
(pprof) top 10

The tagignore=db filter excludes samples tagged with database activity (network, syscalls waiting on the server), leaving only driver-side CPU work visible. To further exclude CESU-8 encoding/decoding overhead, add tagignore=cesu8:

(pprof) tagignore=db,cesu8
(pprof) top 10

Performance

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

Dependencies

  • Please see go.mod.

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

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Goclientdatabase-driverdrivergo

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库