Created
November 11, 2025 07:41
-
-
Save kavirajk/81428effcb2a59bc4eadc03053ac8d36 to your computer and use it in GitHub Desktop.
Query Params clickhouse-go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "context" | |
| "fmt" | |
| "os" | |
| "github.com/ClickHouse/clickhouse-go/v2" | |
| ) | |
| func main() { | |
| conn, err := clickhouse.Open(&clickhouse.Options{ | |
| Protocol: clickhouse.HTTP, | |
| Addr: []string{"localhost:8123"}, | |
| }) | |
| if err != nil { | |
| fmt.Fprintf(os.Stderr, "Failed to connect: %v\n", err) | |
| os.Exit(1) | |
| } | |
| defer conn.Close() | |
| chCtx := clickhouse.Context(context.Background(), clickhouse.WithParameters(clickhouse.Parameters{ | |
| "array": "['a', 'b', 'c', 'hello', 'testing']", | |
| "column": "number", | |
| "database": "system", | |
| "table": "numbers", | |
| })) | |
| row := conn.QueryRow(chCtx, "SELECT {column:Identifier} v, {array:Array(String)} a FROM {database:Identifier}.{table:Identifier} LIMIT 1 OFFSET 100") | |
| var ( | |
| col1 uint64 | |
| col3 []string | |
| ) | |
| if err := row.Scan(&col1, &col3); err != nil { | |
| panic(err) | |
| } | |
| fmt.Printf("row: col1=%d, col3=%s\n", col1, col3) | |
| } |
Author
kavirajk
commented
Nov 11, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment