Skip to main content

...About 1 min

Go Native API


  • golang >= 1.13
  • make >= 3.0
  • curl >= 7.1.1
  • thrift 0.13.x
  • Linux、Macos or other unix-like systems
  • Windows+bash (WSL、cygwin、Git Bash)


  • go mod
export GO111MODULE=on
export GOPROXY=

mkdir session_example && cd session_example

curl -o session_example.go -L

go mod init session_example
go run session_example.go
# get thrift 0.13.0
go get
cd $GOPATH/src/
git checkout 0.13.0

mkdir -p $GOPATH/src/iotdb-client-go-example/session_example
cd $GOPATH/src/iotdb-client-go-example/session_example
curl -o session_example.go -L
go run session_example.go

How to Use the SessionPool

SessionPool is a wrapper of a Session Set. Using SessionPool, the user do not need to consider how to reuse a session connection.
If there is no available connections and the pool reaches its max size, the all methods will hang until there is a available connection.
The PutBack method must be called after use

New sessionPool

config := &client.PoolConfig{
    Host:     host,
    Port:     port,
    UserName: user,
    Password: password,
sessionPool = client.NewSessionPool(config, 3, 60000, 60000, false)

Get session through sessionPool, putback after use

set storage group

session, err := sessionPool.GetSession()
defer sessionPool.PutBack(session)
if err == nil {

query statement

var timeout int64 = 1000
session, err := sessionPool.GetSession()
defer sessionPool.PutBack(session)
if err != nil {
sessionDataSet, err := session.ExecuteQueryStatement(sql, &timeout)
if err == nil {
    defer sessionDataSet.Close()
} else {

Copyright © 2024 The Apache Software Foundation.
Apache and the Apache feather logo are trademarks of The Apache Software Foundation

Have a question? Connect with us on QQ, WeChat, or Slack. Join the community now.