ScyllaDB University Live | Free Virtual Training Event
Learn more
ScyllaDB Documentation Logo Documentation
  • Deployments
    • Cloud
    • Server
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
    • Supported Driver Versions
  • Resources
    • ScyllaDB University
    • Community Forum
    • Tutorials
Install
Search Ask AI
ScyllaDB Docs ScyllaDB gocql driver Quick start
For AI agents: a documentation index is available at https://gocql-driver.docs.scylladb.com/master/llms.txt. A Markdown version of this page is at https://gocql-driver.docs.scylladb.com/master/quick-start.md.

Caution

You're viewing documentation for a previous version of ScyllaDB gocql driver. Switch to the latest stable version.

Quick start¶

Supported Go versions¶

The module’s go.mod declares Go 1.25 as its minimum version. CI builds and tests with that version.

Install¶

This driver is a drop-in replacement for github.com/gocql/gocql and retains that module path for compatibility. Add the replacement, then require the package:

go mod edit -replace=github.com/gocql/gocql=github.com/scylladb/gocql@v1.20.0
go get github.com/gocql/gocql

Replace v1.20.0 with the intended released v1 tag or a pseudo-version. The module path has no /v2 suffix, so v2 tags cannot be used here. See available releases. Run go mod tidy after adding the Go source below.

Run ScyllaDB locally¶

Start a single-node ScyllaDB instance:

docker run --name scylla --rm -p 127.0.0.1:9042:9042 -d scylladb/scylla:6.1.2 \
  --overprovisioned 1 \
  --smp 1

The detached container starts before its CQL service is ready. Wait until a query succeeds before running the Go program:

until docker exec scylla cqlsh -e \
  "SELECT release_version FROM system.local" >/dev/null 2>&1; do
  sleep 1
done

Connect and run a query¶

Create a cluster configuration, enable token-aware host selection, then create a session:

package main

import (
	"fmt"
	"log"

	"github.com/gocql/gocql"
)

func main() {
	cluster := gocql.NewCluster("127.0.0.1")
	cluster.PoolConfig.HostSelectionPolicy = gocql.TokenAwareHostPolicy(
		gocql.RoundRobinHostPolicy(),
	)

	session, err := cluster.CreateSession()
	if err != nil {
		log.Fatal(err)
	}
	defer session.Close()

	var releaseVersion string
	if err := session.Query(
		"SELECT release_version FROM system.local",
	).Scan(&releaseVersion); err != nil {
		log.Fatal(err)
	}

	fmt.Println("connected to ScyllaDB", releaseVersion)
}

Continue with Connecting to the cluster and Executing CQL statements before using the driver in a production deployment.

Was this page helpful?

PREVIOUS
ScyllaDB gocql driver
NEXT
Connecting to the cluster
  • Create an issue
  • Edit this page

On this page

  • Quick start
    • Supported Go versions
    • Install
    • Run ScyllaDB locally
    • Connect and run a query
ScyllaDB gocql driver
Search Ask AI
  • master
    • master
    • v1.20.0
    • v1.19.0
    • v1.18.3
    • v1.18.2
    • v1.18.1
  • Quick start
  • Connecting to the cluster
    • Compression
    • Authentication
    • TLS
    • Client routes (PrivateLink / Private Service Connect)
  • Executing CQL statements
    • Paging
    • Batch statements
    • Lightweight transactions
    • Request timeouts
  • Data types
  • Load balancing
  • Retry policy configuration
  • Speculative execution
Docs Tutorials University Contact Us About Us
© 2026 ScyllaDB | Terms of Service | Privacy Policy | ScyllaDB, and ScyllaDB Cloud, are registered trademarks of ScyllaDB, Inc.
Last updated on 08 Oct 2026.
Powered by Sphinx 9.1.0 & ScyllaDB Theme 1.9.3