chdb-go

command module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

chDB-go

chdb-go

chDB go bindings and chDB cli.

Install

  1. Download and install libchdb
  • run make update_libchdb to download and extract libchdb.so. or
  • run make install to install libchdb.so
  1. Build chdb-go
  • run make build
  1. Run chdb-go with or without persistent --path
  • run ./chdb-go

chdb-go CLI

  1. Simple mode
./chdb-go "SELECT 123"
./chdb-go "SELECT 123" JSON
  1. Interactive mode
./chdb-go # enter interactive mode, but data will be lost after exit
./chdb-go --path /tmp/chdb # interactive persistent mode
Go lib Example
package main

import (
    "fmt"
    "github.com/chdb-io/chdb-go/chdb"
)

func main() {
    // Stateless Query (ephemeral)
    result := chdb.Query("SELECT version()", "CSV")
    fmt.Println(result)

    // Stateful Query (persistent)
    session, _ := NewSession(path)
    defer session.Cleanup()

    session.Query("CREATE DATABASE IF NOT EXISTS testdb; " +
    "CREATE TABLE IF NOT EXISTS testdb.testtable (id UInt32) ENGINE = MergeTree() ORDER BY id;")

    session.Query("USE testdb; INSERT INTO testtable VALUES (1), (2), (3);")

    ret := session.Query("SELECT * FROM testtable;")
    fmt.Println(ret)
}
Golang API docs

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL