Created
October 3, 2025 09:53
-
-
Save kavirajk/549bb4ca4c757040d1c994ea2f845ef8 to your computer and use it in GitHub Desktop.
withstdAsync_driverConn.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
| func TestWithStdAsync(t *testing.T) { | |
| conn, err := clickhouse.Open(&clickhouse.Options{ | |
| Addr: []string{"localhost:9000"}, | |
| Protocol: clickhouse.Native, | |
| }) | |
| require.NoError(t, err) | |
| ctx := context.Background() | |
| queryID := fmt.Sprintf("%d", time.Now().Unix()) | |
| // queryID := "async-with-opendb" | |
| ctx = clickhouse.Context(ctx, clickhouse.WithStdAsync(true), clickhouse.WithQueryID(queryID)) | |
| err = conn.Exec(ctx, `DROP TABLE IF EXISTS example`) | |
| require.NoError(t, err) | |
| const ddl = ` | |
| CREATE TABLE example ( | |
| Col1 UInt64 | |
| , Col2 String | |
| , Col3 Array(UInt8) | |
| , Col4 DateTime | |
| ) ENGINE = Memory | |
| ` | |
| require.NoError(t, conn.Exec(ctx, ddl)) | |
| for i := 0; i < 100; i++ { | |
| err := conn.Exec(ctx, `INSERT INTO example VALUES (?, ?, ?, now())`, i, "Golang", []uint8{1, 2, 4}) | |
| require.NoError(t, err) | |
| } | |
| fmt.Println("QueryID", queryID) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This one doesnt' respect the async settings passed in via context.