id stringlengths 36 36 | document stringlengths 3 3k | metadata stringlengths 23 69 | embeddings listlengths 384 384 |
|---|---|---|---|
8e690c4b-14c5-4393-bbbb-66accfcc7062 | Now Grafana will see the results of the alias table instead of the results from
DESC example_table
:
Both types of aliasing can be used to perform complex type conversions or JSON field extraction.
All YAML options {#all-yaml-options}
These are all of the YAML configuration options made available by the plugin.... | {"source_file": "config.md"} | [
-0.10111738741397858,
0.011910910718142986,
-0.045331958681344986,
-0.009549847804009914,
-0.08327840268611908,
-0.08854611217975616,
-0.06032722070813179,
-0.03739726543426514,
-0.011242221109569073,
0.05352409929037094,
0.027951324358582497,
-0.060898952186107635,
-0.03177853301167488,
-... |
9f5509a3-2e7a-42b8-b514-3c8a6afbcda0 | sidebar_label: 'Query Builder'
sidebar_position: 2
slug: /integrations/grafana/query-builder
description: 'Using the Query Builder in the ClickHouse Grafana plugin'
title: 'Query Builder'
doc_type: 'guide'
keywords: ['grafana', 'query builder', 'visualization', 'dashboards', 'plugin']
import Image from '@theme/Idea... | {"source_file": "query-builder.md"} | [
-0.048638541251420975,
0.058568213135004044,
-0.038518860936164856,
0.05437993258237839,
-0.061452411115169525,
-0.004407224711030722,
-0.007459629792720079,
0.05267786979675293,
-0.03731360659003258,
0.015193847008049488,
0.028439415618777275,
-0.0653594359755516,
0.07056548446416855,
-0.... |
496205a0-299a-4396-ab04-b6bbc128d89d | Table {#table}
The most flexible query type is the table query. This is a catch-all for the other query builders designed to handle simple and aggregate queries.
| Field | Description |
|----|----|
| Builder Mode | Simple queries exclude Aggregates and Group By, while aggregate queries include these options. |
| ... | {"source_file": "query-builder.md"} | [
-0.01917649246752262,
0.00209156540222466,
-0.0024863029830157757,
0.09643885493278503,
-0.0021704440005123615,
-0.01535074133425951,
0.016996759921312332,
0.02109619416296482,
0.024535106495022774,
0.053694434463977814,
-0.00612984923645854,
0.012265895493328571,
0.03910267725586891,
0.01... |
e6e6b896-d394-4d8e-a790-b1287f77ad26 | Extra columns that are selected in the query can be viewed in the expanded log row:
Time series {#time-series}
The time series query type is similar to
table
, but with a focus on time series data.
The two views are mostly the same, with these notable differences:
- A dedicated
Time
field.
- In Aggregate mode... | {"source_file": "query-builder.md"} | [
-0.022095656022429466,
-0.03239075094461441,
0.007855177856981754,
0.0763702243566513,
-0.014702466316521168,
0.006236612796783447,
-0.027436843141913414,
0.024137387052178383,
0.048905257135629654,
0.010050494223833084,
0.007351268548518419,
-0.05338384211063385,
-0.03164982795715332,
0.0... |
9cb5071d-4b1e-4b41-80b8-b56f55a5e45e | The trace query type supports
data links
.
| Field | Description |
|----|----|
| Trace Mode | Changes the query from Trace Search to Trace ID lookup. |
| Use OTel | Enables OpenTelemetry columns. Will overwrite the selected columns to use columns defined by the selected OTel schema version (Disables column selection... | {"source_file": "query-builder.md"} | [
-0.09180589765310287,
-0.05956374108791351,
-0.08456944674253464,
0.04453536495566368,
-0.06838320940732956,
-0.08113797754049301,
-0.02736021764576435,
-0.011932672001421452,
-0.02563396282494068,
-0.009705672971904278,
0.022051431238651276,
-0.04222242534160614,
-0.006952309515327215,
-0... |
d3f58709-768c-44d9-8116-cb560f946008 | If OpenTelemetry is enabled in a
log
or
trace
query, a trace ID column will be included automatically.
By including a trace ID column, the "
View Trace
" and "
View Logs
" links will be attached to the data.
Linking abilities {#linking-abilities}
With the data links present, you can open traces and logs using... | {"source_file": "query-builder.md"} | [
0.025415822863578796,
-0.08675207942724228,
-0.05050109326839447,
0.1119411289691925,
0.040575604885816574,
0.0013216338120400906,
0.04614570364356041,
-0.006032389122992754,
-0.009527930989861488,
-0.031624626368284225,
-0.005552250891923904,
0.0022768231574445963,
0.024098161607980728,
-... |
e1dbcdf5-0e85-48cd-a39d-47d091e91ea1 | | Macro | Description | Output example ... | {"source_file": "query-builder.md"} | [
0.0463205948472023,
0.06437702476978302,
-0.006618929095566273,
0.01438852772116661,
-0.03264516592025757,
0.07528968155384064,
0.03532673418521881,
0.05860888585448265,
0.026235060766339302,
-0.0348186120390892,
0.01559611689299345,
-0.08186733722686768,
0.00738520547747612,
-0.0477271936... |
a5a95081-9a86-4737-95eb-82aa897302c1 | |
$__toTime_ms
| Replaced by the ending time of the panel range cast to a
DateTime64
. |
fromUnixTimestamp64Milli(1447328726456)
|
|
$__timeInterval(colum... | {"source_file": "query-builder.md"} | [
0.04010468348860741,
0.02849976345896721,
-0.051090095192193985,
0.00929525401443243,
-0.015015932731330395,
0.06246240809559822,
0.003108585486188531,
0.08842765539884567,
-0.0071031940169632435,
0.02209365740418434,
-0.02238929644227028,
-0.10610245168209076,
0.010208048857748508,
-0.030... |
dee52084-ee6b-4b9b-be8b-4ba3d5b7948e | sidebar_label: 'Quick Start'
sidebar_position: 1
slug: /integrations/grafana
description: 'Introduction to using ClickHouse with Grafana'
title: 'ClickHouse data source plugin for Grafana'
show_related_blogs: true
doc_type: 'guide'
integration:
- support_level: 'partner'
- category: 'data_visualization'
- website... | {"source_file": "index.md"} | [
-0.09041120111942291,
0.0035623875446617603,
-0.07097353041172028,
0.019235141575336456,
-0.0613352470099926,
-0.028556309640407562,
-0.008357150480151176,
0.010819785296916962,
-0.07914819568395615,
0.01808328367769718,
0.039939381182193756,
-0.045520566403865814,
0.03223831206560135,
-0.... |
9ad8c3f8-29dd-4b43-a387-3f06a34a7b1c | On the next screen, click the
Install
button:
4. Define a ClickHouse data source {#4-define-a-clickhouse-data-source}
Once the installation is complete, click the
Add new data source
button. (You can also add a data source from the
Data sources
tab on the
Connections
page.)
Either scroll d... | {"source_file": "index.md"} | [
-0.095210000872612,
-0.07360979169607162,
-0.14927588403224945,
-0.048701174557209015,
-0.11039425432682037,
-0.05627606809139252,
-0.035195596516132355,
-0.0815369263291359,
-0.042613208293914795,
0.019377848133444786,
0.036669109016656876,
-0.024735165759921074,
-0.030185949057340622,
0.... |
52dddd26-c5c3-4ef2-bd87-6cc6faf8bdf4 | sidebar_label: 'Go'
sidebar_position: 1
keywords: ['clickhouse', 'go', 'client', 'golang']
slug: /integrations/go
description: 'The Go clients for ClickHouse allows users to connect to ClickHouse using either the Go standard database/sql interface or an optimized native interface.'
title: 'ClickHouse Go'
doc_type: 'ref... | {"source_file": "index.md"} | [
0.02933814935386181,
-0.011773264966905117,
-0.09473123401403427,
0.0038542000111192465,
-0.11064542084932327,
0.03795555233955383,
0.06998895108699799,
0.052205830812454224,
-0.13273003697395325,
-0.06811246275901794,
0.029473448172211647,
-0.03644883632659912,
0.06598342210054398,
0.0238... |
905274f4-2faa-4aba-8716-9ede146e4c75 | if err != nil {
return nil, err
}
if err := conn.Ping(ctx); err != nil {
if exception, ok := err.(*clickhouse.Exception); ok {
fmt.Printf("Exception [%d] %s \n%s\n", exception.Code, exception.Message, exception.StackTrace)
}
return nil, err
... | {"source_file": "index.md"} | [
0.027705945074558258,
0.022493980824947357,
-0.0592329204082489,
-0.006525856908410788,
-0.04032609984278679,
-0.06607135385274887,
0.03679738938808441,
0.0370384082198143,
-0.03158872202038765,
-0.06298309564590454,
0.020824506878852844,
-0.049132101237773895,
-0.05531872808933258,
0.0344... |
0975f6f2-af11-4122-882b-90315fc3f41b | When choosing a client library, users should be aware of their respective pros and cons - see Choosing a Client Library.
| | Native format | Native protocol | HTTP protocol | Row Orientated API | Column Orientated API | Type flexibility | Compression | Query Placeholders |
|:-------------:|:------------... | {"source_file": "index.md"} | [
-0.10247790813446045,
0.07085651904344559,
-0.05938427150249481,
-0.013575919903814793,
-0.009987562894821167,
-0.022129632532596588,
-0.05854491889476776,
0.007456020452082157,
0.03781191259622574,
-0.026927107945084572,
-0.037697684019804,
0.019557103514671326,
0.044143516570329666,
0.01... |
440955d3-68bc-44b9-b293-c4a8ab64076c | Both interfaces encode data using the
native format
and native protocol for communication. Additionally, the standard interface supports communication over HTTP.
| | Native format | Native protocol | HTTP protocol | Bulk write support | Struct marshaling | Compression | Query Placeholders |
|:---... | {"source_file": "index.md"} | [
-0.042043134570121765,
-0.011354943737387657,
-0.10859565436840057,
-0.0008395086624659598,
-0.05921675264835358,
-0.0740339383482933,
-0.017913756892085075,
-0.025239737704396248,
-0.08937785029411316,
-0.08595722168684006,
0.03307635709643364,
-0.038917236030101776,
0.06386927515268326,
... |
1ab0084e-ed4d-4350-bcf5-fe941f07f829 | Note we use the default native port to connect.
go
conn, err := clickhouse.Open(&clickhouse.Options{
Addr: []string{fmt.Sprintf("%s:%d", env.Host, env.Port)},
Auth: clickhouse.Auth{
Database: env.Database,
Username: env.Username,
Password: env.Password,
},
})
if err != nil {
re... | {"source_file": "index.md"} | [
0.0035053235478699207,
-0.01599114015698433,
-0.14720945060253143,
-0.03573094308376312,
-0.08942313492298126,
-0.04534660652279854,
-0.001539324875921011,
0.021011827513575554,
-0.042365144938230515,
-0.04737504944205284,
0.06358204036951065,
0.009601124562323093,
-0.006338471546769142,
0... |
c3aa680c-75f5-4895-8bb4-9f6f101fcf20 | go
conn, err := clickhouse.Open(&clickhouse.Options{
Addr: []string{fmt.Sprintf("%s:%d", env.Host, env.Port)},
Auth: clickhouse.Auth{
Database: env.Database,
Username: env.Username,
Password: env.Password,
},
DialContext: func(ctx context.Context, addr string) (net.Conn, error) {... | {"source_file": "index.md"} | [
-0.01428529154509306,
0.010371439158916473,
-0.09965711086988449,
-0.03991790860891342,
-0.06641419976949692,
-0.0751820057630539,
-0.012017474509775639,
0.06859243661165237,
-0.012059852480888367,
-0.02713671699166298,
0.021495046094059944,
-0.032938402146101,
-0.045485444366931915,
0.035... |
e20eabcf-ce5d-445f-81f8-62b0fbe7be2b | go
env, err := GetNativeTestEnvironment()
if err != nil {
return err
}
cwd, err := os.Getwd()
if err != nil {
return err
}
t := &tls.Config{}
caCert, err := ioutil.ReadFile(path.Join(cwd, "../../tests/resources/CAroot.crt"))
if err != nil {
return err
}
caCertPool := x509.NewCertPool()
successful := caCertP... | {"source_file": "index.md"} | [
0.010351181961596012,
0.06757372617721558,
-0.09809337556362152,
0.009889434091746807,
-0.004346109461039305,
-0.11016938835382462,
0.03306557610630989,
0.05936867371201515,
0.0010928751435130835,
-0.03469455614686012,
0.06197724863886833,
-0.15474270284175873,
0.023149680346250534,
0.0757... |
06ac1560-f40f-4357-a0a2-8cbe01d0133a | Full Example
Two connection strategies are available:
ConnOpenInOrder
(default) - addresses are consumed in order. Later addresses are only utilized in case of failure to connect using addresses earlier in the list. This is effectively a failure-over strategy.
ConnOpenRoundRobin
- Load is balanced across the... | {"source_file": "index.md"} | [
0.012482287362217903,
-0.005614349618554115,
-0.1134883463382721,
0.021288609132170677,
-0.0731198713183403,
-0.052505385130643845,
0.008387643843889236,
-0.012318192049860954,
-0.02345358580350876,
0.0063097248785197735,
0.008310288190841675,
0.05895952507853508,
0.021342959254980087,
0.0... |
9a47e13b-2b68-4d37-a1fe-9493397eb49a | batch, err := conn.PrepareBatch(ctx, "INSERT INTO example")
if err != nil {
return err
}
defer batch.Close()
for i := 0; i < 1000; i++ {
err := batch.Append(
uint8(42),
"ClickHouse",
"Inc",
uuid.New(),
map[string]uint8{"key": 1}, // Map(String, UInt8)
... | {"source_file": "index.md"} | [
-0.026033876463770866,
0.024075128138065338,
-0.03481355309486389,
0.027206484228372574,
-0.11952167749404907,
-0.045376844704151154,
0.10496600717306137,
-0.010847741737961769,
-0.09798358380794525,
-0.03503434360027313,
0.05725761130452156,
-0.031914420425891876,
0.061691541224718094,
-0... |
8e7f63ea-509a-4a77-9f53-8f553c349b94 | Full Example
Note in both cases, we are required to pass a pointer to the variables we wish to serialize the respective column values into. These must be passed in the order specified in the
SELECT
statement - by default, the order of column declaration will be used in the event of a
SELECT *
as shown above.
Si... | {"source_file": "index.md"} | [
-0.027195360511541367,
0.02764158882200718,
-0.17251110076904297,
0.07790055125951767,
-0.07477673888206482,
0.009697736240923405,
0.06035579368472099,
0.03540607541799545,
-0.03929069638252258,
-0.05668863654136658,
0.02567516826093197,
0.026869257912039757,
0.06592537462711334,
-0.008910... |
46e21dbc-d47b-4639-93d5-33b3bfce7c5b | return batch.Send()
```
Full Example
Using structs {#using-structs}
For users, Golang structs provide a logical representation of a row of data in ClickHouse. To assist with this, the native interface provides several convenient functions.
Select with serialize {#select-with-serialize}
The Select method allow... | {"source_file": "index.md"} | [
0.021433202549815178,
0.016752948984503746,
-0.10973105579614639,
0.043815214186906815,
-0.05109797418117523,
-0.0911555215716362,
0.0954541489481926,
0.0652245357632637,
-0.10215144604444504,
-0.07247000187635422,
0.04475915804505348,
-0.007034833077341318,
-0.01499274093657732,
0.0336517... |
92909d04-bebf-4923-957c-26acb14c826f | The type conversions currently supported for primitive types are captured
here
.
This effort is ongoing and can be separated into insertion (
Append
/
AppendRow
) and read time (via a
Scan
). Should you need support for a specific conversion, please raise an issue.
Complex types {#complex-types}
Date/DateTime t... | {"source_file": "index.md"} | [
0.05447590723633766,
0.005944777745753527,
-0.09706360101699829,
0.01763804256916046,
-0.05051379278302193,
0.011362305842339993,
0.01914202608168125,
0.03954727202653885,
-0.07642097026109695,
-0.028916098177433014,
-0.03057924285531044,
-0.05782131105661392,
0.01650054007768631,
0.019538... |
3c771201-da96-4e4a-85c7-7e1f0f9441b6 | Full Example
Map {#map}
Maps should be inserted as Golang maps with keys and values conforming to the type rules defined
earlier
.
```go
batch, err := conn.PrepareBatch(ctx, "INSERT INTO example")
if err != nil {
return err
}
defer batch.Close()
var i int64
for i = 0; i < 10; i++ {
err := batch.Append(... | {"source_file": "index.md"} | [
0.07012470066547394,
0.051135748624801636,
-0.017094753682613373,
-0.029130740091204643,
-0.13518498837947845,
0.008825501427054405,
0.028255226090550423,
0.044811833649873734,
-0.10640321671962738,
-0.049873825162649155,
0.07072976231575012,
-0.015825975686311722,
-0.019294319674372673,
-... |
e2f94e3d-4e49-47cf-a274-8c5b362d2579 | Full Example
Note: typed slices and maps are supported, provide the sub-columns in the named tuple are all of the same types.
Nested {#nested}
A Nested field is equivalent to an Array of named Tuples. Usage depends on whether the user has set
flatten_nested
to 1 or 0.
By setting flatten_nested to 0, Nested co... | {"source_file": "index.md"} | [
0.02945834770798683,
0.014781526289880276,
-0.056001823395490646,
0.0019394056871533394,
-0.020590685307979584,
-0.04634776711463928,
0.03282848373055458,
0.027473313733935356,
-0.12005428969860077,
-0.017985733225941658,
0.024525802582502365,
-0.0722922682762146,
-0.01235067006200552,
0.0... |
823e1f81-3e89-46e9-a0e9-f6d7f3069d3b | Full Example -
flatten_tested=0
If the default value of 1 is used for
flatten_nested
, nested columns are flattened to separate arrays. This requires using nested slices for insertion and retrieval. While arbitrary levels of nesting may work, this is not officially supported.
``go
conn, err := GetNativeConnection... | {"source_file": "index.md"} | [
0.015324954874813557,
-0.06344723701477051,
-0.06856007128953934,
0.06246855854988098,
-0.015864934772253036,
-0.09391729533672333,
0.02372748777270317,
0.07182369381189346,
-0.11440416425466537,
-0.02491012029349804,
0.03119581565260887,
-0.05614802613854408,
-0.018226031213998795,
0.0069... |
0bad8ac4-b2f7-4d5a-89b1-45553ebbeafd | batch, err := conn.PrepareBatch(ctx, "INSERT INTO example")
if err != nil {
return err
}
defer batch.Close()
if err = batch.Append(
orb.Point{11, 22},
orb.Ring{
orb.Point{1, 2},
orb.Point{1, 2},
},
orb.Polygon{
orb.Ring{
orb.Point{1, 2},
orb.Point{12... | {"source_file": "index.md"} | [
0.023549439385533333,
0.016673492267727852,
-0.04227771610021591,
-0.02127949893474579,
-0.034248512238264084,
-0.08577936142683029,
0.10728122293949127,
-0.02346721477806568,
-0.03089054301381111,
-0.044536370784044266,
0.029122713953256607,
-0.01135391928255558,
0.04669102653861046,
-0.0... |
cce55273-a791-4f1a-bce7-c91d6c0bb812 | if err = batch.Send(); err != nil {
return err
}
var (
col1 decimal.Decimal
col2 decimal.Decimal
col3 decimal.Decimal
col4 decimal.Decimal
col5 decimal.Decimal
)
if err = conn.QueryRow(ctx, "SELECT * FROM example").Scan(&col1, &col2, &col3, &col4, &col5); err != nil {
return err
}
fmt.Pr... | {"source_file": "index.md"} | [
0.0033194595016539097,
0.015889709815382957,
-0.12640489637851715,
0.08134742081165314,
-0.06568832695484161,
-0.05177063122391701,
0.052054956555366516,
0.05106634646654129,
-0.09174322336912155,
-0.03336142748594284,
0.018789179623126984,
-0.06009935587644577,
-0.024705585092306137,
-0.0... |
81c799d9-834f-462d-bf40-18e0371caa4c | batch, err := conn.PrepareBatch(ctx, "INSERT INTO example")
if err != nil {
return err
}
defer batch.Close()
col1Data, _ := new(big.Int).SetString("170141183460469231731687303715884105727", 10)
col2Data := big.NewInt(128)
col3Data := []
big.Int{
big.NewInt(-128),
big.NewInt(128128),
big.NewInt(1281281... | {"source_file": "index.md"} | [
0.022855505347251892,
-0.021618790924549103,
-0.04279362037777901,
-0.003643104573711753,
-0.0962074026465416,
-0.08235635608434677,
-0.03219741955399513,
0.031040582805871964,
-0.12010084092617035,
0.004326505120843649,
-0.0016071520512923598,
-0.039485443383455276,
0.0012269065482541919,
... |
19104ff4-a6dc-46b7-bc18-9a48d196ac73 | go
var count uint64
// positional bind
if err = conn.QueryRow(ctx, "SELECT count() FROM example WHERE Col1 >= ? AND Col3 < ?", 500, now.Add(time.Duration(750)*time.Second)).Scan(&count); err != nil {
return err
}
// 250
fmt.Printf("Positional bind count: %d\n", count)
// numeric bind
if err = conn.QueryRow(ctx, "SE... | {"source_file": "index.md"} | [
0.06351649761199951,
-0.038680631667375565,
-0.06859367340803146,
0.03331071138381958,
-0.09938305616378784,
-0.01181596890091896,
0.04316822066903114,
0.05601617321372032,
0.013871475122869015,
-0.03398120403289795,
0.025354323908686638,
-0.032985687255859375,
0.061499692499637604,
-0.048... |
a66db880-a057-40d4-82c6-8742b485a333 | Full Example
Using context {#using-context}
Go contexts provide a means of passing deadlines, cancellation signals, and other request-scoped values across API boundaries. All methods on a connection accept a context as their first variable. While previous examples used context.Background(), users can use this capab... | {"source_file": "index.md"} | [
-0.07447312772274017,
0.053038280457258224,
-0.09445880353450775,
0.0011893005575984716,
-0.10645310580730438,
-0.01145562157034874,
0.11256017535924911,
0.007795796263962984,
0.010263302363455296,
-0.02567017823457718,
-0.000204453244805336,
-0.03900031000375748,
0.05643922835588455,
-0.0... |
95175900-40bc-480b-b5dd-aef91c6802ab | // set a deadline for a query - this will cancel the query after the absolute time is reached.
// queries will continue to completion in ClickHouse
ctx, cancel = context.WithDeadline(context.Background(), time.Now().Add(-time.Second))
defer cancel()
if err := conn.Ping(ctx); err == nil {
return fmt.Errorf("expected... | {"source_file": "index.md"} | [
-0.019716624170541763,
0.022941388189792633,
-0.017239956185221672,
0.05916881561279297,
-0.02019413746893406,
-0.0988713949918747,
0.060401059687137604,
-0.02699941396713257,
-0.006485366728156805,
-0.008610839024186134,
-0.0018992341356351972,
-0.04463280364871025,
-0.017245711758732796,
... |
ef25dfaf-d6ca-4a7e-a7ff-21e66e2a0f79 | fmt.Printf("Total Rows: %d\n", totalRows)
rows.Close()
```
Full Example
Dynamic scanning {#dynamic-scanning}
Users may need to read tables for which they do not know the schema or type of the fields being returned. This is common in cases where ad-hoc data analysis is performed or generic tooling is written. To a... | {"source_file": "index.md"} | [
0.04659042879939079,
0.06082179769873619,
-0.09602165967226028,
0.12619540095329285,
-0.03290199488401413,
-0.07608916610479355,
0.09968782216310501,
0.07577106356620789,
-0.08686578273773193,
-0.05839169770479202,
-0.0064473142847418785,
0.007447259500622749,
-0.03199922293424606,
0.00436... |
0872eec0-e485-4769-bd62-f7dc6b8cd7f7 | var count uint64
if err := conn.QueryRow(ctx, "SELECT COUNT(
) FROM external_table_1").Scan(&count); err != nil {
return err
}
fmt.Printf("external_table_1: %d\n", count)
if err := conn.QueryRow(ctx, "SELECT COUNT(
) FROM external_table_2").Scan(&count); err != nil {
return err
}
fmt.Printf("external_table_2: %... | {"source_file": "index.md"} | [
0.038089554756879807,
-0.02472592331469059,
-0.07472044974565506,
0.06062643602490425,
-0.007999022491276264,
-0.09972554445266724,
0.09605559706687927,
0.09076593816280365,
-0.048997074365615845,
-0.02567649818956852,
0.06426502019166946,
-0.06355327367782593,
0.06485534459352493,
-0.0585... |
eb48fbea-e41d-4ab4-a4aa-de105e050047 | ```go
func Connect() error {
env, err := GetStdTestEnvironment()
if err != nil {
return err
}
conn := clickhouse.OpenDB(&clickhouse.Options{
Addr: []string{fmt.Sprintf("%s:%d", env.Host, env.Port)},
Auth: clickhouse.Auth{
... | {"source_file": "index.md"} | [
0.03280875086784363,
-0.052622389048337936,
-0.11085986346006393,
-0.014051140286028385,
-0.06049586832523346,
-0.03749197721481323,
0.015992091968655586,
0.03717736899852753,
-0.05492662265896797,
-0.018330244347453117,
0.016871510073542595,
-0.035793159157037735,
-0.021083056926727295,
0... |
d6fb7607-4534-4ffe-9797-cf9905fac97f | skip_verify
- skip certificate verification (default is
false
)
block_buffer_size
- allows users to control the block buffer size. See
BlockBufferSize
. (default is
2
)
go
func ConnectSettings() error {
env, err := GetStdTestEnvironment()
if err != nil {
return err
}
... | {"source_file": "index.md"} | [
0.025048233568668365,
0.061572857201099396,
-0.11743662506341934,
-0.00870101060718298,
-0.008334146812558174,
-0.08529640734195709,
0.07009485363960266,
0.020910998806357384,
-0.061027493327856064,
-0.020494403317570686,
0.023733731359243393,
-0.024415744468569756,
-0.005877216812223196,
... |
3398cefb-f497-432c-98e5-dfb58f2e915f | For DSN-based connections, the string accepts multiple hosts and a
connection_open_strategy
parameter for which the value
round_robin
or
in_order
can be set.
```go
func MultiStdHost() error {
env, err := GetStdTestEnvironment()
if err != nil {
return err
}
conn, e... | {"source_file": "index.md"} | [
0.02618490718305111,
-0.023439079523086548,
-0.14019536972045898,
-0.010950186289846897,
-0.08456610888242722,
-0.06327734887599945,
0.00012777688971254975,
0.029434440657496452,
-0.04607071354985237,
-0.032949671149253845,
-0.00918519962579012,
-0.0038725584745407104,
-0.026763824746012688,... |
dbbe5178-19f7-4c9c-bdb2-95f58aaa6509 | }
func ConnectDSNSSL() error {
env, err := GetStdTestEnvironment()
if err != nil {
return err
}
conn, err := sql.Open("clickhouse", fmt.Sprintf("https://%s:%d?secure=true&skip_verify=true&username=%s&password=%s", env.Host, env.HttpsPort, env.Username, env.Password))
... | {"source_file": "index.md"} | [
-0.04417688399553299,
-0.01685931347310543,
-0.13119155168533325,
-0.000826966657768935,
-0.049510207027196884,
-0.06655293703079224,
0.03235604986548424,
0.06388821452856064,
-0.021273503080010414,
-0.03750044107437134,
-0.01147119514644146,
-0.009144757874310017,
0.024763982743024826,
0.... |
c89a2f70-5943-4baa-86ce-36f70538648e | go
batch, err := scope.Prepare("INSERT INTO example")
if err != nil {
return err
}
for i := 0; i < 1000; i++ {
_, err := batch.Exec(
uint8(42),
"ClickHouse", "Inc",
uuid.New(),
map[string]uint8{"key": 1}, // Map(String, UInt8)
[]string{"Q", "W", "E", "R", "T",... | {"source_file": "index.md"} | [
0.003971728961914778,
0.03707234561443329,
-0.026000095531344414,
0.015745069831609726,
-0.1090526357293129,
-0.024838274344801903,
0.09136952459812164,
-0.01993914507329464,
-0.10384131222963333,
-0.01242354791611433,
0.05925694853067398,
-0.029770782217383385,
0.013055162504315376,
-0.00... |
e67b17c3-0598-4e64-81d1-591fa602a603 | go
const ddl = `
CREATE TABLE example (
Col1 UInt64
, Col2 String
, Col3 Array(UInt8)
, Col4 DateTime
) ENGINE = Memory
`
if _, err := conn.Exec(ddl); err != nil {
return err
}
ctx := clickhouse.Context(context.Background(), clickhouse.WithStdAsync(false))
{
for i... | {"source_file": "index.md"} | [
0.02989455871284008,
-0.02396346814930439,
-0.11974504590034485,
0.03606473281979561,
-0.0657220110297203,
-0.046331290155649185,
0.045557718724012375,
0.07690586894750595,
-0.07218274474143982,
-0.01811189390718937,
0.05474970489740372,
-0.032121866941452026,
0.002234425861388445,
-0.0200... |
5c662182-2dd8-4f17-9e98-a3937f3889b8 | Full Example
Insert behavior is the same as the ClickHouse API.
Compression {#compression-1}
The standard API supports the same compression algorithms as native
ClickHouse API
i.e.
lz4
and
zstd
compression at a block level. In addition, gzip, deflate and br compression are supported for HTTP connections. If... | {"source_file": "index.md"} | [
-0.0743727907538414,
0.00485199736431241,
-0.11024242639541626,
0.06649938225746155,
-0.009795483201742172,
-0.07377006858587265,
-0.028587084263563156,
-0.004101582802832127,
-0.005764069501310587,
-0.03700092434883118,
-0.057529184967279434,
0.08003205060958862,
0.038591522723436356,
-0.... |
0baf358e-add3-4cb6-94ba-bea2661a6b46 | go
var count uint64
// positional bind
if err = conn.QueryRow(ctx, "SELECT count() FROM example WHERE Col1 >= ? AND Col3 < ?", 500, now.Add(time.Duration(750)*time.Second)).Scan(&count); err != nil {
return err
}
// 250
fmt.Printf("Positional bind count: %d\n", count)
// numeric bind
if err = conn.QueryRow(ctx, "SE... | {"source_file": "index.md"} | [
0.06351649761199951,
-0.038680631667375565,
-0.06859367340803146,
0.03331071138381958,
-0.09938305616378784,
-0.01181596890091896,
0.04316822066903114,
0.05601617321372032,
0.013871475122869015,
-0.03398120403289795,
0.025354323908686638,
-0.032985687255859375,
0.061499692499637604,
-0.048... |
efa4fc4e-0e98-48a2-84d6-03f00933b0a3 | // set a query id to assist tracing queries in logs e.g. see system.query_log
var one uint8
ctx = clickhouse.Context(context.Background(), clickhouse.WithQueryID(uuid.NewString()))
if err = conn.QueryRowContext(ctx, "SELECT 1").Scan(&one); err != nil {
return err
}
conn.ExecContext(context.Background(), "DROP QUO... | {"source_file": "index.md"} | [
-0.07554128021001816,
-0.011798392049968243,
-0.06567132472991943,
0.06040661409497261,
-0.08185736835002899,
-0.056343924254179,
0.14927950501441956,
0.008057528175413609,
0.03409494459629059,
-0.003939390182495117,
-0.02070096880197525,
-0.0970120057463646,
0.05744178593158722,
-0.029521... |
78e83bb4-a366-40fc-9037-3e904934a30e | Full Example
Dynamic scanning {#dynamic-scanning-1}
Similar to the
ClickHouse API
, column type information is available to allow users to create runtime instances of correctly typed variables which can be passed to Scan. This allows columns to be read where the type is not known.
go
const query = `
SELECT
... | {"source_file": "index.md"} | [
0.020243195816874504,
0.01417178101837635,
-0.10330481827259064,
0.09404585510492325,
-0.03488845005631447,
-0.04794951155781746,
0.08412451297044754,
0.039159249514341354,
-0.10803943127393723,
-0.09106161445379257,
-0.010881495662033558,
0.018230395391583443,
0.004671749658882618,
0.0375... |
893bbe64-b082-4329-8098-d1c01f58648b | Full Example
Open telemetry {#open-telemetry-1}
ClickHouse allows a
trace context
to be passed as part of the native protocol. The client allows a Span to be created via the function
clickhouse.withSpan
and passed via the Context to achieve this. This is not supported when HTTP is used as transport.
go
var co... | {"source_file": "index.md"} | [
0.02855968475341797,
-0.040726691484451294,
-0.0913168415427208,
0.04164661094546318,
-0.03433360531926155,
-0.07976523041725159,
0.12203458696603775,
0.005645619705319405,
0.0016672107158228755,
-0.03705984726548195,
0.027598228305578232,
0.013461645692586899,
0.01766490936279297,
-0.0128... |
28afcb16-2887-4d61-852a-064cef47a318 | sidebar_label: 'Advanced Inserting'
sidebar_position: 5
keywords: ['clickhouse', 'python', 'insert', 'advanced']
description: 'Advanced Inserting with ClickHouse Connect'
slug: /integrations/language-clients/python/advanced-inserting
title: 'Advanced Inserting'
doc_type: 'reference'
Inserting data with ClickHouse C... | {"source_file": "advanced-inserting.md"} | [
-0.025435741990804672,
-0.022029587998986244,
-0.04109521210193634,
0.0724455937743187,
-0.09740090370178223,
-0.018320027738809586,
0.023171190172433853,
0.02975141815841198,
-0.0626935139298439,
-0.011199683882296085,
0.06944604218006134,
0.0023938820231705904,
0.11033493280410767,
-0.06... |
e9494216-837d-4d3a-89ef-529f7d0d0155 | | ClickHouse Type | Native Python Type | Write Formats | Comments |
|-----------------------|-------------------------|-------------------|-------------------------------------------------------------------... | {"source_file": "advanced-inserting.md"} | [
-0.023651115596294403,
0.0011578816920518875,
-0.13633474707603455,
-0.008949181996285915,
-0.05894972011446953,
-0.10561346262693405,
0.013333704322576523,
0.04760371148586273,
-0.06549476832151413,
-0.054204218089580536,
0.010586608201265335,
-0.08680595457553864,
0.025954168289899826,
0... |
66980582-e6e0-4087-b19c-c8098ec71d6a | | DateTime64 | datetime.datetime | int | Python datetime.datetime is limited to microsecond precision. The raw 64 bit int value is available |
| Time | datetime.timedelta | int, string, time | ClickHouse stores DateTime in epoch seconds. int types will be ass... | {"source_file": "advanced-inserting.md"} | [
-0.02253599837422371,
0.02101954258978367,
-0.03616553917527199,
-0.018679574131965637,
-0.09128992259502411,
-0.06673648208379745,
-0.10405107587575912,
-0.01128420140594244,
-0.03306521847844124,
-0.041469208896160126,
0.005107345059514046,
-0.044400617480278015,
-0.048720259219408035,
-... |
3658c952-95dd-401b-9a1f-1e7b2aaff922 | Specialized insert methods {#specialized-insert-methods}
ClickHouse Connect provides specialized insert methods for common data formats:
insert_df
-- Insert a Pandas DataFrame. Instead of a Python Sequence of Sequences
data
argument, the second parameter of this method requires a
df
argument that must be a P... | {"source_file": "advanced-inserting.md"} | [
-0.02721036970615387,
-0.14681392908096313,
-0.12725314497947693,
0.006647138856351376,
-0.07895257323980331,
-0.07791635394096375,
-0.05322285741567612,
-0.03508380427956581,
-0.0642232745885849,
0.0013184247072786093,
0.04784364625811577,
0.06768833845853806,
-0.03738163039088249,
0.0083... |
c64bc98b-de91-4b91-ad7f-06d948bbcc33 | Timezone-aware datetime objects {#timezone-aware-datetime-objects}
If you insert a timezone-aware Python
datetime.datetime
object, ClickHouse Connect will automatically call
.timestamp()
to convert it to a Unix timestamp, which correctly accounts for the timezone offset. This means you can insert datetime objects... | {"source_file": "advanced-inserting.md"} | [
0.04864205792546272,
-0.04216340556740761,
-0.03774641454219818,
0.018343614414334297,
0.012840560637414455,
-0.08649180084466934,
-0.008075088262557983,
-0.03175313025712967,
0.018469762057065964,
0.0025973618030548096,
-0.038413140922784805,
-0.05742170289158821,
-0.08186522126197815,
0.... |
91af8dd2-5923-4c42-af2c-650d0c452c72 | DateTime columns with timezone metadata {#datetime-columns-with-timezone-metadata}
ClickHouse columns can be defined with timezone metadata (e.g.,
DateTime('America/Denver')
or
DateTime64(3, 'Asia/Tokyo')
). This metadata doesn't affect how data is stored (still as UTC timestamps), but it controls the timezone use... | {"source_file": "advanced-inserting.md"} | [
0.10242974758148193,
-0.04610525071620941,
-0.07141166180372238,
0.008131883107125759,
0.0016085626557469368,
-0.10208522528409958,
-0.00995299220085144,
-0.027424132451415062,
0.022461656481027603,
0.008207297883927822,
0.014313954859972,
-0.03216699883341789,
-0.041811518371105194,
0.028... |
bf813995-d6b4-4421-9211-fbedc4e081c9 | | Parameter | Type | Default | Description |
|--------------|-----------------|-------------------|---------------------------------------------------------------------------------------... | {"source_file": "advanced-inserting.md"} | [
-0.0005824867403134704,
-0.03332158923149109,
-0.12375921756029129,
0.02682046964764595,
-0.1035052090883255,
0.019171463325619698,
0.030128998681902885,
0.025187982246279716,
-0.03856927901506424,
0.02255917340517044,
0.06785313785076141,
-0.09197982400655746,
0.12386184185743332,
-0.0508... |
dc566e53-3dc9-44a0-8c01-dad39587da91 | sidebar_label: 'SQLAlchemy'
sidebar_position: 7
keywords: ['clickhouse', 'python', 'sqlalchemy', 'integrate']
description: 'ClickHouse SQLAlchemy Support'
slug: /integrations/language-clients/python/sqlalchemy
title: 'SQLAlchemy Support'
doc_type: 'reference'
ClickHouse Connect includes a SQLAlchemy dialect (
click... | {"source_file": "sqlalchemy.md"} | [
-0.013024838641285896,
-0.06132502108812332,
-0.08103258162736893,
0.04322221875190735,
-0.08707565069198608,
-0.06188341602683067,
0.03920846804976463,
0.02364172600209713,
-0.1149633526802063,
-0.06598424166440964,
-0.038753122091293335,
0.022519521415233612,
0.11845008283853531,
-0.0158... |
4c95d483-e0ce-4825-a4ca-45bb2bfdb39f | with engine.begin() as conn:
# Databases
conn.execute(CreateDatabase("example_db", exists_ok=True))
# Tables
metadata = MetaData(schema="example_db")
table = db.Table(
"events",
metadata,
db.Column("id", UInt32, primary_key=True),
db.Column("user", String),
db.Column("created_at", DateTime... | {"source_file": "sqlalchemy.md"} | [
-0.0038758227601647377,
-0.07588138431310654,
-0.05607587844133377,
0.04574494808912277,
-0.0762137696146965,
-0.08883555978536606,
-0.0019061649218201637,
0.012090845964848995,
-0.06587543338537216,
0.011500939726829529,
0.027319058775901794,
-0.03283055126667023,
0.06634580343961716,
-0.... |
272c5847-3a0a-47dd-97c2-bfba9e58b3a4 | Transactions and server features: Two-phase transactions, sequences,
RETURNING
, and advanced isolation levels are not supported.
engine.begin()
provides a Python context manager for grouping statements but performs no actual transaction control (commit/rollback are no-ops). | {"source_file": "sqlalchemy.md"} | [
-0.08006508648395538,
-0.03859934210777283,
-0.06372334063053131,
0.06168222799897194,
-0.05575733259320259,
-0.04303085431456566,
0.0013605505228042603,
-0.051404569298028946,
0.02671508863568306,
-0.04066172614693642,
0.08044490963220596,
0.05247000977396965,
-0.026461811736226082,
-0.02... |
e1a2f355-2f42-457c-8b8d-b838e431f79a | sidebar_label: 'Driver API'
sidebar_position: 2
keywords: ['clickhouse', 'python', 'driver', 'api', 'client']
description: 'ClickHouse Connect Driver API'
slug: /integrations/language-clients/python/driver-api
title: 'ClickHouse Connect Driver API'
doc_type: 'reference'
ClickHouse Connect driver API {#clickhouse-co... | {"source_file": "driver-api.md"} | [
-0.030699055641889572,
0.03270450234413147,
-0.06090985983610153,
0.018601568415760994,
-0.06024380773305893,
-0.019489800557494164,
0.03660418093204498,
0.0356382355093956,
-0.11024416983127594,
-0.09739255160093307,
0.03706304728984833,
0.014225604012608528,
0.0745292380452156,
-0.035833... |
1f288010-d839-4f49-b196-409283ed4e59 | | Parameter | Type | Default | Description ... | {"source_file": "driver-api.md"} | [
0.03499232977628708,
0.05151437595486641,
-0.03347549960017204,
0.01007634587585926,
-0.08359705656766891,
0.042122550308704376,
0.027290377765893936,
0.04243069514632225,
0.0028166708070784807,
-0.0498807393014431,
0.020550336688756943,
-0.054090991616249084,
-0.012340902350842953,
-0.062... |
cff95196-7fd9-497b-8042-6f2d2adbf4a9 | | dsn | str |
None
| A string in standard DSN (Data Source Name) format. Other connection values (such as host or user) will be extracted from this string if not set otherwise. ... | {"source_file": "driver-api.md"} | [
-0.06050261855125427,
-0.013577330857515335,
-0.10453357547521591,
0.0710795670747757,
-0.08160685747861862,
-0.07360489666461945,
-0.051160238683223724,
0.009344304911792278,
-0.026363367214798927,
-0.019071128219366074,
-0.021394414827227592,
0.034676533192396164,
0.034311361610889435,
-... |
b15f52de-0164-4663-b9a1-5fa00a16d9ec | | https_proxy | str |
None
| HTTPS proxy address (equivalent to setting the HTTPS_PROXY environment variable). ... | {"source_file": "driver-api.md"} | [
-0.024272486567497253,
0.01524997316300869,
-0.07438433915376663,
-0.012548856437206268,
-0.09832897782325745,
-0.06110097095370293,
-0.0499795638024807,
-0.04645860940217972,
-0.07455770671367645,
-0.015191031619906425,
-0.027524644508957863,
-0.02901727706193924,
0.030231818556785583,
-0... |
72fed02a-fff8-4051-b324-1003a774ce43 | HTTPS/TLS arguments {#httpstls-arguments}
| Parameter | Type | Default | Description ... | {"source_file": "driver-api.md"} | [
-0.019003765657544136,
0.08503501862287521,
0.005065098404884338,
-0.012156755663454533,
-0.09321760386228561,
-0.09741544723510742,
-0.03376298025250435,
-0.03584050014615059,
0.08466028422117233,
-0.0679180771112442,
-0.02089720219373703,
-0.06855718046426773,
0.03869045525789261,
-0.004... |
6ea15df4-6b99-4d3d-ba5e-2bef7d9829f3 | Settings argument {#settings-argument}
Finally, the
settings
argument to
get_client
is used to pass additional ClickHouse settings to the server for each client request. Note that in most cases, users with
readonly
=
1
access cannot alter settings sent with a query, so ClickHouse Connect will drop such settings... | {"source_file": "driver-api.md"} | [
0.005230261478573084,
0.024288715794682503,
-0.07449445873498917,
0.05389169603586197,
-0.09597151726484299,
-0.03344239667057991,
0.03998967260122299,
-0.019466714933514595,
-0.029390016570687294,
-0.03886514902114868,
0.0012738548684865236,
-0.006422265432775021,
0.0635770633816719,
-0.0... |
f2506cd7-ca61-4eb9-b22f-8aefac0fe45f | ```python
import clickhouse_connect
client = clickhouse_connect.get_client()
print(client.server_version)
Output: '22.10.1.98'
```
Connecting to a secure (HTTPS) external ClickHouse server
```python
import clickhouse_connect
client = clickhouse_connect.get_client(host='play.clickhouse.com', secure=True,... | {"source_file": "driver-api.md"} | [
0.0475650392472744,
-0.024417245760560036,
-0.09339822828769684,
-0.06091658025979996,
-0.10048727691173553,
-0.041703350841999054,
-0.00846768356859684,
-0.03840749338269234,
0.00411501619964838,
-0.024132460355758667,
-0.019632427021861076,
0.0001991791359614581,
0.007762175519019365,
-0... |
d991cb31-dd57-4015-8a34-6d1626367b23 | To share a client across threads safely:
```python
import clickhouse_connect
import threading
Option 1: Disable sessions (recommended for shared clients)
client = clickhouse_connect.get_client(
host='my-host',
username='default',
password='password',
autogenerate_session_id=False # Required for t... | {"source_file": "driver-api.md"} | [
-0.047509945929050446,
-0.012546972371637821,
-0.046658873558044434,
-0.02312159724533558,
-0.049363087862730026,
-0.06768353283405304,
0.04429401084780693,
-0.06364630907773972,
0.016031861305236816,
0.005394283682107925,
-0.04109247401356697,
0.028655139729380608,
0.024183567613363266,
-... |
9eeb71df-bdf0-473a-acbd-1a35c0cef83f | Several client methods use one or both of the common
parameters
and
settings
arguments. These keyword arguments are described below.
Parameters argument {#parameters-argument}
ClickHouse Connect Client
query*
and
command
methods accept an optional
parameters
keyword argument used for binding Python expres... | {"source_file": "driver-api.md"} | [
-0.07316069304943085,
-0.018957102671265602,
-0.026643645018339157,
0.08633580058813095,
-0.11716648936271667,
-0.046872060745954514,
0.03621269017457962,
0.06693802773952484,
-0.03519735857844353,
-0.016380181536078453,
-0.02217276580631733,
-0.029835492372512817,
0.053633373230695724,
-0... |
e745798c-23af-41aa-8b29-b29ca1f1fc79 | Example with Python Sequence (Tuple), Float64, and IPv4Address
```python
import ipaddress
parameters = (35200.44, ipaddress.IPv4Address(0x443d04fe))
client.query('SELECT * FROM some_table WHERE metric >= %s AND ip_address = %s', parameters=parameters)
```
This generates the following query on the server:
sql
... | {"source_file": "driver-api.md"} | [
-0.005653642117977142,
-0.009579317644238472,
-0.022607170045375824,
0.04108491167426109,
-0.1322583556175232,
-0.04784930869936943,
0.0007907964172773063,
-0.021133892238140106,
-0.0015260705258697271,
-0.013040577061474323,
-0.028510665521025658,
-0.05656181648373604,
0.0026242099702358246... |
d4dbe575-63ee-40ae-a5d5-87175aa7b004 | | Parameter | Type | Default | Description |
|---------------|------------------|------------|-------------------------------------------------------------... | {"source_file": "driver-api.md"} | [
0.012592684477567673,
0.04801523685455322,
-0.04700368270277977,
0.047229163348674774,
-0.10644417256116867,
0.01349152997136116,
0.0999564379453659,
0.032506298273801804,
-0.058167070150375366,
-0.00893375277519226,
0.0560963898897171,
-0.1437196135520935,
0.05448371544480324,
-0.03184879... |
99d85dce-bff3-436b-a750-78e2f7274910 | Using client-side parameters
table_name = "system"
result = client.command(
"SELECT count() FROM system.tables WHERE database = %(db)s",
parameters={"db": table_name}
)
Using server-side parameters
result = client.command(
"SELECT count() FROM system.tables WHERE database = {db:String}",
parameter... | {"source_file": "driver-api.md"} | [
0.03199150040745735,
-0.011169526726007462,
-0.0962318405508995,
0.0961856096982956,
-0.12118826806545258,
-0.08812073618173599,
0.0610855370759964,
0.04758710041642189,
-0.0782555565237999,
0.020034309476614,
0.03849603608250618,
0.010348460637032986,
0.11569159477949142,
-0.0992895513772... |
a1dfc20b-c2c5-4ae9-b221-8f45bc9dedcb | | Parameter | Type | Default | Description |
|---------------------|------------------|------------|----------------------------... | {"source_file": "driver-api.md"} | [
0.021260017529129982,
0.04729067161679268,
-0.026857471093535423,
0.03133001551032066,
-0.09367003291845322,
0.022610589861869812,
0.0035456998739391565,
0.04207440838217735,
0.019403712823987007,
-0.044501449912786484,
0.029866086319088936,
-0.10939890891313553,
0.026621447876095772,
-0.0... |
f1f53e00-a0cc-44c7-924e-65c1ba01dc0a | | use_extended_dtypes | bool | True | Use Pandas extended dtypes (like StringArray), and pandas.NA and pandas.NaT for ClickHouse NULL values. Applies only to
query_df
and
query_df_stream
methods. |
| external_data | ExternalData |
None
| An ExternalData object cont... | {"source_file": "driver-api.md"} | [
0.016673007979989052,
-0.03165837377309799,
-0.10797716677188873,
-0.00039861261029727757,
0.04243101924657822,
-0.053606051951646805,
0.06734555214643478,
-0.010717042721807957,
-0.07286646962165833,
0.034437790513038635,
0.0776529610157013,
-0.07863947749137878,
-0.04578549787402153,
-0.... |
2d6a7576-69d0-4aa3-9337-3d425cb5237a | Query examples {#query-examples}
Basic query {#basic-query}
```python
import clickhouse_connect
client = clickhouse_connect.get_client()
Simple SELECT query
result = client.query("SELECT name, database FROM system.tables LIMIT 3")
Access results as rows
for row in result.result_rows:
print(row)
Outp... | {"source_file": "driver-api.md"} | [
0.06695118546485901,
0.023906074464321136,
-0.10786009579896927,
0.01870659925043583,
-0.11674077063798904,
-0.043058283627033234,
0.06364641338586807,
0.026703165844082832,
-0.04625459760427475,
-0.04009293019771576,
0.03320338949561119,
0.03169502690434456,
0.06586454063653946,
-0.114653... |
307d232d-3b22-4422-a183-96a6639b1bda | The
QueryResult
object {#the-queryresult-object}
The base
query
method returns a
QueryResult
object with the following public properties:
result_rows
-- A matrix of the data returned in the form of a Sequence of rows, with each row element being a sequence of column values.
result_columns
-- A matrix of... | {"source_file": "driver-api.md"} | [
-0.021436994895339012,
-0.0030901951249688864,
-0.09600533545017242,
0.07249932736158371,
-0.04314592480659485,
-0.042975787073373795,
0.051772136241197586,
0.02370787411928177,
-0.0321161225438118,
0.0024566829670220613,
0.007185156457126141,
-0.031027140095829964,
0.05230668932199478,
-0... |
cedf34f7-d595-48a5-94ff-57076c4ad355 | | Parameter | Type | Default | Description |
|--------------------|----------------------------------... | {"source_file": "driver-api.md"} | [
0.03516434505581856,
0.05118449032306671,
-0.03394487872719765,
0.009712180122733116,
-0.08392764627933502,
0.0417565181851387,
0.027765460312366486,
0.04239678010344505,
0.0023341961205005646,
-0.05041023716330528,
0.021036097779870033,
-0.054108526557683945,
-0.0121467849239707,
-0.06290... |
21143c99-d662-41f8-b68d-ba52084de0d7 | Advanced Inserts (InsertContexts)
|
| transport_settings | dict |
None
| Optional dictionary of transport-level settings (HTTP headers, etc.) ... | {"source_file": "driver-api.md"} | [
0.01609276421368122,
-0.023082785308361053,
-0.10294351726770401,
0.06790834665298462,
-0.039419032633304596,
-0.040609151124954224,
0.007726551964879036,
0.03560807555913925,
-0.09520383924245834,
-0.004698386415839195,
0.06178011745214462,
-0.06637584418058395,
0.09060035645961761,
-0.00... |
a94490e4-c0a5-47f4-aaaa-bb83275d3d1d | This method returns a "query summary" dictionary as described under the "command" method. An exception will be raised if the insert fails for any reason.
For specialized insert methods that work with Pandas DataFrames, PyArrow Tables, and Arrow-backed DataFrames, see
Advanced Inserting (Specialized Insert Methods)
.... | {"source_file": "driver-api.md"} | [
0.014974110759794712,
-0.03292694315314293,
-0.09456661343574524,
-0.0030789843294769526,
-0.08496299386024475,
-0.061150867491960526,
0.01384126115590334,
-0.01374317891895771,
-0.107016421854496,
0.012672184035182,
0.10002284497022629,
0.030751578509807587,
0.03688441589474678,
-0.045544... |
f8c297cd-4fd1-48c9-bdca-84327fa0da3b | Exceptions {#exceptions}
All custom exceptions (including those defined in the DB API 2.0 specification) are defined in the
clickhouse_connect.driver.exceptions
module. Exceptions actually detected by the driver will use one of these types.
ClickHouse SQL utilities {#clickhouse-sql-utilities}
The functions and ... | {"source_file": "driver-api.md"} | [
-0.0010606938740238547,
-0.04224880784749985,
-0.0317859910428524,
0.05674099922180176,
-0.06366227567195892,
-0.04129597172141075,
0.003671149490401149,
0.007718196138739586,
-0.08401060849428177,
-0.0458407886326313,
-0.005247277207672596,
-0.04306884482502937,
0.05536724627017975,
-0.08... |
c2eb124e-cde1-4782-aac8-a1d805c05f58 | keywords: ['clickhouse', 'python', 'client', 'connect', 'integrate']
slug: /integrations/python
description: 'The ClickHouse Connect project suite for connecting Python to ClickHouse'
title: 'Python Integration with ClickHouse Connect'
doc_type: 'guide'
integration:
- support_level: 'core'
- category: 'language_cli... | {"source_file": "index.md"} | [
-0.01151339989155531,
-0.0360354520380497,
-0.0901934802532196,
0.017124729230999947,
-0.08058059960603714,
-0.05137604475021362,
0.06510347872972488,
0.031913939863443375,
-0.11797573417425156,
-0.024216046556830406,
-0.005966278724372387,
-0.001422137371264398,
0.07909394800662994,
-0.01... |
9d4e21ac-bdaa-4819-9a07-ff43392c6532 | This documentation is current as of the clickhouse-connect release 0.9.2.
:::note
The official ClickHouse Connect Python driver uses the HTTP protocol for communication with the ClickHouse server. This enables HTTP load balancer support and works well in enterprise environments with firewalls and proxies, but has sli... | {"source_file": "index.md"} | [
-0.08470720797777176,
-0.024300139397382736,
-0.08504058420658112,
0.017991529777646065,
-0.08485700935125351,
-0.12294312566518784,
0.0013049650005996227,
-0.04445257410407066,
-0.04577872157096863,
-0.05301488935947418,
-0.0048577371053397655,
0.05925150215625763,
0.027120644226670265,
-... |
b783225d-91a7-47c2-914e-902cb1403f23 | Support policy {#support-policy}
Please update to the latest version of ClickHouse Connect before reporting any issues. Issues should be filed in the
GitHub project
. Future releases of ClickHouse Connect are intended be compatible with actively supported ClickHouse versions at the time of release. Actively supporte... | {"source_file": "index.md"} | [
-0.07224417477846146,
-0.02915593795478344,
-0.09631956368684769,
-0.01769159361720085,
-0.08081077039241791,
-0.013479194603860378,
-0.07111956179141998,
-0.10003433376550674,
-0.041751179844141006,
0.05661371722817421,
0.04255736991763115,
0.009828482754528522,
0.0022684773430228233,
0.0... |
13ec8a6e-a9bf-4849-8eda-f7651dbbf0e0 | sidebar_label: 'Advanced Usage'
sidebar_position: 6
keywords: ['clickhouse', 'python', 'advanced', 'raw', 'async', 'threading']
description: 'Advanced Usage with ClickHouse Connect'
slug: /integrations/language-clients/python/advanced-usage
title: 'Advanced Usage'
doc_type: 'reference'
Advanced Usage {#advanced-usa... | {"source_file": "advanced-usage.md"} | [
-0.0790288969874382,
0.021263059228658676,
-0.07617399841547012,
0.05647560581564903,
-0.10374122112989426,
-0.06912051141262054,
0.017288926988840103,
0.03134090453386307,
-0.05986415967345238,
-0.045565683394670486,
0.020057549700140953,
0.002006473019719124,
0.0587804839015007,
-0.05603... |
2d847020-d2da-4384-9411-3c753d47c7ab | Client
raw_insert
method {#client-rawinsert-method}
The
Client.raw_insert
method allows direct inserts of
bytes
objects or
bytes
object generators using the client connection. Because it does no processing of the insert payload, it is highly performant. The method provides options to specify settings and inse... | {"source_file": "advanced-usage.md"} | [
-0.0030848870519548655,
-0.02159876562654972,
-0.09602592885494232,
0.04871038720011711,
-0.10706966370344162,
-0.043639130890369415,
-0.07533787935972214,
0.049879010766744614,
-0.02333103120326996,
0.04123279079794884,
0.020495140925049782,
-0.11593624204397202,
0.0990184098482132,
-0.05... |
7beb9f05-b0eb-4a43-84bc-2e24b4f447a8 | Multithreaded, multiprocess, and async/event driven use cases {#multithreaded-multiprocess-and-asyncevent-driven-use-cases}
ClickHouse Connect works well in multithreaded, multiprocess, and event-loop-driven/asynchronous applications. All query and insert processing occurs within a single thread, so operations are ge... | {"source_file": "advanced-usage.md"} | [
-0.06758242100477219,
-0.07930152863264084,
-0.07919012755155563,
-0.03065270557999611,
-0.033364973962306976,
-0.006908191833645105,
0.05294224992394447,
-0.005938488990068436,
0.05861310660839081,
0.006337140686810017,
-0.015015555545687675,
0.002032087417319417,
0.02190590091049671,
-0.... |
10c3b242-0f3a-43cb-96df-4ea0e4575349 | By default, each query executed with a ClickHouse Connect
Client
instance uses that client's session ID.
SET
statements and temporary tables work as expected when using a single client. However, the ClickHouse server does not allow concurrent queries within the same session (the client will raise a
ProgrammingErro... | {"source_file": "advanced-usage.md"} | [
-0.02148885652422905,
-0.02963981404900551,
-0.047930099070072174,
0.038782812654972076,
-0.12681300938129425,
-0.08069679141044617,
0.07778769731521606,
-0.04024443030357361,
0.008426652289927006,
-0.00047325529158115387,
0.004278105683624744,
0.006158843170851469,
0.09063579887151718,
-0... |
81e58619-e54c-46bb-aba3-de8cfe417f65 | sidebar_label: 'Additional Options'
sidebar_position: 3
keywords: ['clickhouse', 'python', 'options', 'settings']
description: 'Additional Options for ClickHouse Connect'
slug: /integrations/language-clients/python/additional-options
title: 'Additional Options'
doc_type: 'reference'
Additional options {#additional-... | {"source_file": "additional-options.md"} | [
-0.043343812227249146,
-0.031381044536828995,
-0.024420883506536484,
0.012499569915235043,
-0.09391582012176514,
0.01678795926272869,
0.030289962887763977,
0.016319233924150467,
-0.09056442975997925,
-0.06441031396389008,
0.03938246890902519,
0.03797179460525513,
0.03639711067080498,
0.016... |
151e1ad7-bd64-4e69-942a-6156df6a9214 | | Setting Name | Default | Options | Description ... | {"source_file": "additional-options.md"} | [
0.00512098940089345,
0.024742376059293747,
-0.02560773305594921,
0.022052526473999023,
-0.08293841779232025,
0.044052015990018845,
0.037744488567113876,
0.04441968351602554,
0.011981790885329247,
-0.04087097942829132,
0.03831908479332924,
-0.06069084629416466,
-0.031243475154042244,
-0.050... |
07f987f6-5c38-488c-9261-aec1dd3f8d22 | | send_integration_tags | True | True, False | Include the used integration libraries/version (e.g. Pandas/SQLAlchemy/etc.) in client information sent to ClickHouse (HTTP User-Agent string). ... | {"source_file": "additional-options.md"} | [
0.008695974946022034,
-0.03538668155670166,
-0.10483121871948242,
-0.013959748670458794,
0.020603274926543236,
-0.11012677103281021,
-0.04944688454270363,
0.005425015930086374,
-0.04909306392073631,
0.013780451379716396,
0.014728739857673645,
-0.02522171102464199,
-0.0008146211039274931,
-... |
0c017b7f-115a-4505-9444-fa21e84f4042 | Compression {#compression}
ClickHouse Connect supports lz4, zstd, brotli, and gzip compression for both query results and inserts. Always keep in mind that using compression usually involves a tradeoff between network bandwidth/transfer speed against CPU usage (both on the client and the server.)
To receive compres... | {"source_file": "additional-options.md"} | [
-0.08346162736415863,
0.02762824110686779,
-0.111094631254673,
0.04446728527545929,
-0.03362144157290459,
-0.07151705771684647,
-0.0460968092083931,
-0.06096932291984558,
-0.041610293090343475,
-0.013384299352765083,
-0.02414310723543167,
0.06569674611091614,
0.05655756965279579,
-0.018040... |
dbe28d6b-79d1-4138-943e-9b2288f49651 | "Old" JSON data type {#old-json-data-type}
The experimental
Object
(or
Object('json')
) data type is deprecated and should be avoided in a production environment. ClickHouse Connect continues to provide limited support for the data type for backward compatibility. Note that this support does not include queries th... | {"source_file": "additional-options.md"} | [
-0.08235551416873932,
-0.03601653128862381,
0.009233089163899422,
0.04943123087286949,
-0.04756375029683113,
-0.06806392222642899,
-0.07488448172807693,
0.00762349646538496,
-0.05441093444824219,
-0.05218110606074333,
0.04874422401189804,
0.03624353185296059,
-0.05112626776099205,
0.083848... |
b9d8dff8-d152-4fd3-b997-cd0cce0ce174 | sidebar_label: 'Advanced Querying'
sidebar_position: 4
keywords: ['clickhouse', 'python', 'query', 'advanced']
description: 'Advanced Querying with ClickHouse Connect'
slug: /integrations/language-clients/python/advanced-querying
title: 'Advanced Querying'
doc_type: 'reference'
Querying data with ClickHouse Connect... | {"source_file": "advanced-querying.md"} | [
-0.03420699015259743,
-0.0063519724644720554,
-0.06698118895292282,
0.09277931600809097,
-0.07828646898269653,
-0.012907953932881355,
0.0734371617436409,
0.027075422927737236,
-0.09830019623041153,
-0.038931362330913544,
0.012557991780340672,
-0.0035557993687689304,
0.09741253405809402,
-0... |
9dc2c8e5-9473-4426-a2f2-955514ff82ac | query_df_stream
-- Returns each ClickHouse Block of query data as a Pandas DataFrame
query_arrow_stream
-- Returns query data in PyArrow RecordBlocks
query_df_arrow_stream
-- Returns each ClickHouse Block of query data as an arrow-backed Pandas DataFrame or a Polars DataFrame depending on the kwarg
dataframe_li... | {"source_file": "advanced-querying.md"} | [
-0.040925219655036926,
-0.06749681383371353,
-0.07687211036682129,
-0.0002618304279167205,
-0.037281304597854614,
-0.08364321291446686,
0.017656106501817703,
-0.019129371270537376,
0.016263162717223167,
-0.0298442505300045,
-0.013895563781261444,
0.036008674651384354,
-0.07116661965847015,
... |
5bdb5499-83e4-447e-b23b-dab2ac896295 | StreamContexts {#streamcontexts}
Each of the
query_*_stream
methods (like
query_row_block_stream
) returns a ClickHouse
StreamContext
object, which is a combined Python context/generator. This is the basic usage:
python
with client.query_row_block_stream('SELECT pickup, dropoff, pickup_longitude, pickup_latitu... | {"source_file": "advanced-querying.md"} | [
-0.05762893334031105,
-0.020437024533748627,
-0.06059806048870087,
0.021617908030748367,
0.02289564721286297,
-0.05449072644114494,
0.11425264179706573,
0.03362710401415825,
-0.02171357534825802,
-0.03396976739168167,
-0.009347442537546158,
-0.04390552639961243,
0.020697440952062607,
0.029... |
3f8d9050-3011-4d48-9aa9-b5c58aa1bedb | The
query_df_stream
method returns each ClickHouse Block as a two-dimensional Pandas DataFrame. Here's an example which shows that the
StreamContext
object can be used as a context in a deferred fashion (but only once).
python
df_stream = client.query_df_stream('SELECT * FROM hits')
column_names = df_stream.sourc... | {"source_file": "advanced-querying.md"} | [
-0.04451907426118851,
-0.12177751958370209,
-0.09945408999919891,
0.012041962705552578,
0.039067067205905914,
-0.07401210814714432,
0.04294794052839279,
-0.04343847557902336,
-0.015213774517178535,
-0.01597798429429531,
0.03578934818506241,
0.01924102008342743,
-0.03788934275507927,
0.0056... |
e22b723f-2611-4997-bbfe-5aede0eb0f6a | Stream Arrow batches {#stream-arrow-batches}
```python
import clickhouse_connect
client = clickhouse_connect.get_client()
Stream query results as Arrow record batches
with client.query_arrow_stream("SELECT * FROM large_table") as stream:
for arrow_batch in stream:
# Process each Arrow batch
... | {"source_file": "advanced-querying.md"} | [
0.016246989369392395,
-0.07783886045217514,
-0.05890851095318794,
0.04032987728714943,
-0.07071764022111893,
-0.0849122479557991,
0.016534212976694107,
-0.03778639808297157,
-0.06638097018003464,
-0.03414793312549591,
-0.0026536290533840656,
0.05960845947265625,
-0.021640317514538765,
-0.0... |
021469ff-0882-4263-8bea-60d81c4ea894 | query_df_arrow
: Executes the query using the ClickHouse
Arrow
output format and returns a DataFrame.
For
dataframe_library='pandas'
, returns a pandas 2.x DataFrame using Arrow‑backed dtypes (
pd.ArrowDtype
). This requires pandas 2.x and leverages zero‑copy buffers where possible for excellent performance and lo... | {"source_file": "advanced-querying.md"} | [
-0.002196437446400523,
-0.13610076904296875,
-0.07113856822252274,
0.0046742637641727924,
0.01335903350263834,
-0.09852936863899231,
0.06695981323719025,
-0.03388306871056557,
0.021795066073536873,
-0.042440325021743774,
0.029192809015512466,
0.08681917190551758,
-0.06156322732567787,
-0.0... |
f23cfb21-7bfb-4af9-a12a-05b77eb9c15b | Pandas requirement: Arrow‑backed dtypes require pandas 2.x. For older pandas versions, use
query_df
(non‑Arrow) instead.
Strings vs binary: The
use_strings
option (when supported by the server setting
output_format_arrow_string_as_string
) controls whether ClickHouse
String
columns are returned as Arrow string... | {"source_file": "advanced-querying.md"} | [
0.05888662859797478,
-0.07545249164104462,
-0.03990842029452324,
0.0075706844218075275,
0.004190060775727034,
-0.09353094547986984,
-0.010540666989982128,
-0.02353546768426895,
-0.050024278461933136,
-0.02057546190917492,
-0.010063592344522476,
0.0007049049017950892,
-0.05646442621946335,
... |
7f43780e-27d1-4b65-ae56-1832a71d7764 | The "data type" argument for any formatting function can include wildcards. The format is a single lower case string.
Read formats can be set at several levels:
Globally, using the methods defined in the
clickhouse_connect.datatypes.format
package. This will control the format of the configured datatype for all... | {"source_file": "advanced-querying.md"} | [
0.06634233891963959,
0.04120934009552002,
-0.028993459418416023,
0.012540658004581928,
-0.09748023748397827,
-0.020201534032821655,
0.021809527650475502,
0.019234919920563698,
-0.07075335830450058,
-0.062157418578863144,
-0.038535743951797485,
0.029530955478549004,
-0.024133315309882164,
-... |
ebc7df3d-30dc-4317-a0d6-9faef889b2ba | | ClickHouse Type | Native Python Type | Read Formats | Comments |
|-----------------------|-------------------------|-------------------|-------------------------------------------------------------... | {"source_file": "advanced-querying.md"} | [
-0.04303152859210968,
-0.034773364663124084,
-0.10458605736494064,
-0.01915709115564823,
-0.05319785699248314,
-0.10376320034265518,
0.02233554609119892,
0.040548134595155716,
-0.10454867780208588,
-0.061451543122529984,
0.029945632442831993,
-0.0048698303289711475,
0.021176155656576157,
-... |
e9db6adf-6710-46f7-b9f1-1c0526e53f31 | | DateTime | datetime.datetime | int | ClickHouse stores DateTime in epoch seconds. This value is available as an int |
| DateTime64 | datetime.datetime | int | Python datetime.datetime is limited to microsecond precision... | {"source_file": "advanced-querying.md"} | [
-0.007767942734062672,
0.02550647035241127,
-0.047461796551942825,
-0.030271681025624275,
-0.039595361799001694,
-0.05911635607481003,
-0.09453155100345612,
0.010296342894434929,
0.0006713197217322886,
-0.024978099390864372,
0.013884627260267735,
-0.030260473489761353,
-0.044932764023542404,... |
e3d8dd83-5e30-4996-950c-73ab845d4946 | External data {#external-data}
ClickHouse queries can accept external data in any ClickHouse format. This binary data is sent along with the query string to be used to process the data. Details of the External Data feature are
here
. The client
query*
methods accept an optional
external_data
parameter to take ad... | {"source_file": "advanced-querying.md"} | [
-0.013826531358063221,
-0.009079087525606155,
-0.0937226340174675,
0.06508243829011917,
-0.07145816087722778,
-0.069285549223423,
0.028508273884654045,
0.020786602050065994,
-0.049941737204790115,
-0.05383332446217537,
-0.012500250712037086,
-0.047662027180194855,
0.04752881079912186,
-0.0... |
47383d93-50e3-4d57-98e9-20ce93dba87e | Additional external data files can be added to the initial
ExternalData
object using the
add_file
method, which takes the same parameters as the constructor. For HTTP, all external data is transmitted as part of a
multi-part/form-data
file upload.
Time zones {#time-zones}
There are multiple mechanisms for app... | {"source_file": "advanced-querying.md"} | [
-0.03061617724597454,
-0.014552352949976921,
-0.07368521392345428,
0.03197844699025154,
0.01935749500989914,
-0.11330991983413696,
-0.057273734360933304,
0.03423311933875084,
0.04914253205060959,
0.01923842914402485,
-0.016463903710246086,
0.009658963419497013,
-0.03934330865740776,
-0.018... |
629bd7ee-c06f-4ab3-8345-02f822ee4e7b | title: 'Java'
keywords: ['clickhouse', 'java', 'jdbc', 'client', 'integrate', 'r2dbc']
description: 'Options for connecting to ClickHouse from Java'
slug: /integrations/java
doc_type: 'reference'
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';
Java c... | {"source_file": "index.md"} | [
-0.054154831916093826,
-0.0590839609503746,
-0.06429921090602875,
-0.035983163863420486,
-0.06359285116195679,
0.012729104608297348,
-0.006892441771924496,
0.03584239259362221,
-0.1027914360165596,
-0.05850761756300926,
-0.06570799648761749,
0.02237480692565441,
0.006762895733118057,
0.043... |
21d14326-962b-4394-83e0-c33dadc4ebb3 | |
Data Type
|
Client V2 Support
|
Client V1 Support
|
|-----------------------|---------------------|---------------------|
|Int8 |✔ |✔ |
|Int16 |✔ |✔ |
|Int32 |✔ ... | {"source_file": "index.md"} | [
0.009479984641075134,
-0.0001681388239376247,
-0.1254422664642334,
-0.02417411468923092,
-0.032876864075660706,
-0.019413119181990623,
0.00458165630698204,
0.062283728271722794,
-0.03685428202152252,
-0.021411431953310966,
0.03273586928844452,
-0.11359595507383347,
0.07042043656110764,
-0.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.