id stringlengths 36 36 | document stringlengths 3 3k | metadata stringlengths 23 69 | embeddings listlengths 384 384 |
|---|---|---|---|
39fb8277-948e-4ce2-8463-05761924abca | JSON for APIs
json_result = chdb.query('SELECT version()', 'JSON')
print(json_result)
Pretty format for debugging
pretty_result = chdb.query('SELECT * FROM system.numbers LIMIT 3', 'Pretty')
print(pretty_result)
```
DataFrame operations {#dataframe-operations}
Legacy DataFrame API {#legacy-dataframe-api}
``... | {"source_file": "python.md"} | [
0.0014469436137005687,
-0.018185393884778023,
0.04497956112027168,
-0.010756285861134529,
-0.002535979263484478,
-0.03841884434223175,
-0.025553178042173386,
0.03633229061961174,
-0.01749761775135994,
-0.012841086834669113,
0.033947959542274475,
-0.0016047804383561015,
-0.05385856702923775,
... |
2e207e36-17ee-4cde-b7cb-80e270e3020e | Create materialized views
sess.query("""
CREATE MATERIALIZED VIEW daily_sales AS
SELECT
sale_date,
count() as orders,
sum(amount) as revenue
FROM sales
GROUP BY sale_date
""")
Query the view
result = sess.query("SELECT * FROM daily_sales ORDER BY sale_date", "Pretty")
pri... | {"source_file": "python.md"} | [
-0.03634520620107651,
0.031390924006700516,
-0.07504408806562424,
0.07390312850475311,
-0.13470855355262756,
-0.04515589401125908,
0.05266699194908142,
0.03522516041994095,
-0.023638639599084854,
0.013691818341612816,
0.00359350792132318,
0.013171014375984669,
0.07880927622318268,
-0.05421... |
c4134348-8f60-4460-a8ff-2604061827d0 | Advanced UDF with custom return types {#advanced-udf-custom-return-types}
```python
UDF with specific return type
@chdb_udf(return_type="Float64")
def calculate_bmi(height_str, weight_str):
height = float(height_str) / 100 # Convert cm to meters
weight = float(weight_str)
return weight / (height * he... | {"source_file": "python.md"} | [
-0.027766704559326172,
0.06897228956222534,
0.014864913187921047,
0.06992380321025848,
-0.049894120544195175,
-0.016091646626591682,
0.06518267095088959,
0.03355700522661209,
-0.05729583650827408,
-0.020435670390725136,
0.009122414514422417,
-0.13873952627182007,
0.026789091527462006,
0.05... |
6c52a2b6-fbdd-4b72-9647-1e2d65f69b6c | # Early termination if needed
if total_rows > 100000:
break
print(f"Total rows processed: {total_rows}")
Example 2: Manual iteration with explicit cleanup
stream = sess.send_query("SELECT * FROM large_data WHERE id % 100 = 0", "JSONEachRow")
processed_count = 0
while True:
chunk = stream.fetch(... | {"source_file": "python.md"} | [
-0.03631693869829178,
0.036599721759557724,
0.02352534420788288,
-0.002614459488540888,
-0.061937689781188965,
-0.07470503449440002,
0.009467129595577717,
0.036542415618896484,
-0.08253433555364609,
-0.015691621229052544,
0.011690751649439335,
0.030756531283259392,
-0.040834806859493256,
-... |
1276836c-0aa9-45d3-b44f-2174a7834321 | Custom data sources with PyReader {#custom-data-sources-pyreader}
Implement custom data readers for specialized data sources:
```python
import chdb
from typing import List, Tuple, Any
import json
class DatabaseReader(chdb.PyReader):
"""Custom reader for database-like data sources"""
def __init__(self, conne... | {"source_file": "python.md"} | [
-0.023261992260813713,
0.0010343861067667603,
-0.11390047520399094,
0.013546361587941647,
-0.12549395859241486,
-0.0377037487924099,
0.055062875151634216,
0.06912019848823547,
-0.06648467481136322,
-0.07086654752492905,
-0.006623027380555868,
-0.039283156394958496,
0.026931727305054665,
-0... |
1fa90068-a5b5-4e0a-a6b6-50729ccbd0a1 | Advanced JSON operations
complex_json = chdb.query("""
SELECT
user_id,
JSONLength(toString(profile)) as json_fields,
JSONType(toString(profile), 'preferences') as pref_type,
if(
JSONHas(toString(profile), 'achievements'),
JSONExtractString(toString(profile)... | {"source_file": "python.md"} | [
-0.0018395850202068686,
0.06640264391899109,
-0.0589081346988678,
0.0011505126021802425,
-0.048282165080308914,
-0.05841516703367233,
0.02603948675096035,
0.06697714328765869,
-0.07054836302995682,
0.005257549695670605,
0.0042096711695194244,
-0.016476759687066078,
-0.009544325061142445,
-... |
eb9a2e13-9fec-4ae6-8942-c97d1ccbfc87 | for batch in batch_reader:
print(f"Processing batch with {batch.num_rows} rows...")
# Transform or export each batch
# df_batch = batch.to_pandas()
# process_batch(df_batch)
stream.close()
sess.close()
```
GitHub repository {#github-repository}
Main Repository
:
chdb-io/chdb
Issues and Suppor... | {"source_file": "python.md"} | [
0.019268976524472237,
-0.0575907863676548,
-0.13656923174858093,
0.021709706634283066,
0.06122028827667236,
-0.006149365101009607,
0.0012970492243766785,
-0.00004020468259113841,
-0.07721854001283646,
0.05682049319148064,
0.03192499279975891,
0.0230756476521492,
-0.023388870060443878,
-0.0... |
275771ac-1c9d-4ff4-9e18-1f6f2f9afe98 | title: 'chDB for C and C++'
sidebar_label: 'C and C++'
slug: /chdb/install/c
description: 'How to install and use chDB with C and C++'
keywords: ['chdb', 'c', 'cpp', 'embedded', 'clickhouse', 'sql', 'olap', 'api']
doc_type: 'guide'
chDB for C and C++
chDB provides a native C/C++ API for embedding ClickHouse funct... | {"source_file": "c.md"} | [
-0.03111855685710907,
-0.0318671278655529,
-0.07811755686998367,
0.05716872587800026,
-0.05252636596560478,
0.04016805812716484,
-0.004295242950320244,
0.054799776524305344,
-0.052438147366046906,
-0.04368148371577263,
-0.015410639345645905,
-0.06742332130670547,
0.09295450896024704,
-0.06... |
ad506467-be98-433a-b73e-4ad46c7d634d | uint64_t chunk_rows = chdb_result_rows_read(chunk);
total_rows += chunk_rows;
printf("Processed chunk: %llu rows, %zu bytes\n", chunk_rows, chunk_length);
// Process the chunk data here
// char* data = chdb_result_buffer(chunk);
chdb_destroy_query_result(chunk);
// Progress reporting
if ... | {"source_file": "c.md"} | [
0.011705633252859116,
0.06642868369817734,
-0.07214930653572083,
-0.014503687620162964,
-0.08766099810600281,
-0.01650616154074669,
-0.006639737170189619,
0.06018966808915138,
-0.015367487445473671,
0.004677139222621918,
-0.030004754662513733,
-0.052946243435144424,
-0.005370707251131535,
... |
aa251db2-0415-4eb3-a7aa-c49e7793fde3 | std::string data(chdb_result_buffer(result), chdb_result_length(result));
// Get query statistics
std::cout << "Query statistics:\n";
std::cout << " Elapsed: " << chdb_result_elapsed(result) << " seconds\n";
std::cout << " Rows read: " << chdb_result_rows_read(result) << "\n";
std::cout << " Byt... | {"source_file": "c.md"} | [
0.03868000581860542,
0.031080007553100586,
-0.08756458759307861,
0.023410361260175705,
-0.16042836010456085,
0.008213807828724384,
0.010132409632205963,
0.08252430707216263,
0.017938919365406036,
0.007048071827739477,
0.04044044390320778,
-0.0828971415758133,
0.07838645577430725,
-0.133908... |
ff12babd-f094-47cb-a88a-ed94587dbb8c | title: 'Installing chDB for Rust'
sidebar_label: 'Rust'
slug: /chdb/install/rust
description: 'How to install and use chDB Rust bindingsd'
keywords: ['chdb', 'embedded', 'clickhouse-lite', 'rust', 'install', 'ffi', 'bindings']
doc_type: 'guide'
chDB for Rust {#chdb-for-rust}
chDB-rust provides experimental FFI (F... | {"source_file": "rust.md"} | [
-0.035792864859104156,
-0.013359639793634415,
-0.04618951678276062,
0.07489810883998871,
-0.04049515724182129,
0.058688051998615265,
0.022904107347130775,
0.04242471233010292,
-0.029435381293296814,
-0.10013492405414581,
-0.06533683091402054,
-0.048234302550554276,
0.050029926002025604,
-0... |
f2906726-5848-4f3b-a1de-c42d3d2c12c5 | Build the project {#build-the-project}
bash
cargo build
Run tests {#run-tests}
bash
cargo test
Development dependencies {#development-dependencies}
The project includes these development dependencies:
-
bindgen
(v0.70.1) - Generate FFI bindings from C headers
-
tempdir
(v0.3.7) - Temporary directory handl... | {"source_file": "rust.md"} | [
-0.08030891418457031,
0.03848765790462494,
-0.016979405656456947,
0.061555661261081696,
0.013523905538022518,
-0.015703357756137848,
-0.029894959181547165,
0.05327528342604637,
-0.034341562539339066,
-0.06277267634868622,
-0.024802058935165405,
-0.1103707030415535,
0.03337452560663223,
-0.... |
8f3e39f0-ad70-45d5-9525-4d92d849b4a8 | title: 'Language Integrations Index'
slug: /chdb/install
description: 'Index page for chDB language integrations'
keywords: ['python', 'NodeJS', 'Go', 'Rust', 'Bun', 'C', 'C++']
doc_type: 'landing-page'
Instructions for how to get setup with chDB are available below for the following languages and runtimes:
| Lan... | {"source_file": "index.md"} | [
0.04059309884905815,
-0.03354872390627861,
-0.038560815155506134,
0.015497047454118729,
-0.05725805461406708,
0.07764478027820587,
-0.01341046392917633,
0.05436445400118828,
-0.07435300201177597,
-0.04478635638952255,
-0.02364182099699974,
-0.0799628347158432,
0.04427166283130646,
-0.00367... |
222a1151-baaf-4750-b0c6-cc9c3c7bc9f7 | title: 'chDB for Node.js'
sidebar_label: 'Node.js'
slug: /chdb/install/nodejs
description: 'How to install and use chDB with Node.js'
keywords: ['chdb', 'nodejs', 'javascript', 'embedded', 'clickhouse', 'sql', 'olap']
doc_type: 'guide'
chDB for Node.js
chDB-node provides Node.js bindings for chDB, enabling you to... | {"source_file": "nodejs.md"} | [
0.006890752352774143,
0.0017572372453287244,
0.00885856430977583,
0.09582941979169846,
0.007299254648387432,
0.005812703166157007,
-0.002061939798295498,
0.04251288250088692,
-0.007069624960422516,
-0.010525520890951157,
-0.05887928605079651,
0.012149843387305737,
0.04050431028008461,
-0.0... |
88523fef-d99c-462c-ad7d-617f1f9555e8 | Processing external data {#processing-external-data}
```javascript
const { Session } = require("chdb");
const session = new Session("./data-processing");
try {
// Process CSV data from URL
const result = session.query(
SELECT
COUNT(*) as total_records,
COUNT(DISTINCT "UserID") as ... | {"source_file": "nodejs.md"} | [
-0.004234796389937401,
-0.005217842757701874,
-0.03992375731468201,
0.07643862813711166,
-0.052973899990320206,
-0.02285056561231613,
0.03867128863930702,
0.05916400998830795,
0.05225445330142975,
0.013347325846552849,
0.0027062769513577223,
-0.08308535814285278,
0.04031434282660484,
-0.02... |
5d8f953a-b0a7-49d0-b74b-599ff292d83c | title: 'How to query Parquet files'
sidebar_label: 'Querying Parquet files'
slug: /chdb/guides/querying-parquet
description: 'Learn how to query Parquet files with chDB.'
keywords: ['chdb', 'parquet']
doc_type: 'guide'
A lot of the world's data lives in Amazon S3 buckets.
In this guide, we'll learn how to query tha... | {"source_file": "querying-parquet.md"} | [
0.0013748627388849854,
-0.021891923621296883,
-0.04537101089954376,
-0.07411344349384308,
-0.025910021737217903,
0.014339885674417019,
0.0022633629851043224,
0.05467495322227478,
-0.010874771513044834,
-0.0083719901740551,
-0.030501171946525574,
-0.002944964449852705,
0.013688778504729271,
... |
0eebe251-a8a4-4ccf-8e0b-f2460e7a3564 | chdb.query(query, 'Vertical')
```
text
Row 1:
──────
num_columns: 15
num_rows: 41905631
num_row_groups: 42
format_version: 2.6
metadata_size: 79730
total_uncompressed_size: 14615827169
total_compressed_size: 9272262304
From this output, we learn that this Par... | {"source_file": "querying-parquet.md"} | [
-0.03756513446569443,
0.03515464812517166,
-0.08156738430261612,
-0.04231417179107666,
-0.038559865206480026,
-0.03651715815067291,
-0.026853030547499657,
0.01252754032611847,
0.03509369120001793,
0.03325216844677925,
-0.0070855156518518925,
0.03855661302804947,
0.03251481056213379,
-0.081... |
6ac6f07a-3202-474e-b4fe-19672838e0cb | chdb.query(query, 'DataFrame')
```
text
name total_compressed_size total_uncompressed_size min max
0 review_date 493 646 ... | {"source_file": "querying-parquet.md"} | [
-0.0062596662901341915,
-0.0038040196523070335,
-0.032130636274814606,
0.057510778307914734,
0.036334212869405746,
0.016136659309267998,
0.05501610413193703,
-0.005290844943374395,
-0.06992214173078537,
0.009760490618646145,
0.0878283679485321,
-0.02365495264530182,
0.02832050994038582,
-0... |
785a95ec-3f9d-4fff-8f88-e502c2b09bac | Querying Parquet files {#querying-parquet-files}
Next, let's query the contents of the file.
We can do this by adjusting the above query to remove
ParquetMetadata
and then, say, compute the most popular
star_rating
across all reviews:
```python
query = """
SELECT star_rating, count() AS count, formatReadableQua... | {"source_file": "querying-parquet.md"} | [
-0.04865901917219162,
-0.050247613340616226,
-0.11288101226091385,
0.028190886601805687,
-0.04174061119556427,
0.0036062204744666815,
0.05147969722747803,
0.015246746130287647,
0.03682218864560127,
0.030200311914086342,
0.03853287920355797,
0.026479264721274376,
0.06896054744720459,
-0.090... |
b7dc767c-084f-4bcb-befe-8c0cdaf92cff | title: 'chDB Guides'
slug: /chdb/guides
description: 'Index page for chDB guides'
keywords: ['chdb', 'guides']
doc_type: 'landing-page'
Take a look at our chDB developer guides below:
| Page | Description |
|-----|-----|
|
How to query a remote ClickHouse server
| In this guide, we will learn how to query a... | {"source_file": "index.md"} | [
0.06898429244756699,
-0.12304288148880005,
-0.018155986443161964,
-0.006457838695496321,
-0.03733781352639198,
-0.01653159223496914,
-0.008371955715119839,
-0.0034533629659563303,
-0.060820408165454865,
0.017256589606404305,
0.03694314509630203,
-0.028886742889881134,
0.008428889326751232,
... |
41c51203-5505-4882-99dd-52ebd3e120f7 | title: 'How to query data in an S3 bucket'
sidebar_label: 'Querying data in S3'
slug: /chdb/guides/querying-s3
description: 'Learn how to query data in an S3 bucket with chDB.'
keywords: ['chdb', 's3']
doc_type: 'guide'
A lot of the world's data lives in Amazon S3 buckets.
In this guide, we'll learn how to query th... | {"source_file": "querying-s3-bucket.md"} | [
0.018933339044451714,
-0.023924481123685837,
-0.03869464620947838,
-0.01446987222880125,
0.015635831281542778,
0.040517959743738174,
-0.0010323749156668782,
0.04845491051673889,
-0.014579413458704948,
-0.00954616628587246,
-0.023415198549628258,
-0.017916793003678322,
0.05873917415738106,
... |
1dcc7c1e-864d-4b0e-ab29-edfa6d109016 | This bucket contains only Parquet files.
Querying files in an S3 bucket {#querying-files-in-an-s3-bucket}
Next, let's learn how to query those files.
If we want to count the number of rows in each of those files, we can run the following query:
python
chdb.query("""
SELECT
_file,
count() AS count,
for... | {"source_file": "querying-s3-bucket.md"} | [
0.011842343024909496,
-0.06208137050271034,
-0.07152571529150009,
-0.01954992674291134,
-0.03413648158311844,
0.03244473412632942,
0.02203674241900444,
0.008796862326562405,
0.0735364705324173,
0.01254919171333313,
0.031244000419974327,
-0.004716846160590649,
0.05566652491688728,
-0.104836... |
bb243ea0-8468-4bcd-b13d-abb4286d7dde | text
┌─product_category─┬──reviews─┬──avg─┐
1. │ Toys │ 4864056 │ 4.21 │
2. │ Apparel │ 5906085 │ 4.11 │
3. │ Luggage │ 348644 │ 4.22 │
4. │ Kitchen │ 4880297 │ 4.21 │
5. │ Books │ 19530930 │ 4.34 │
6. │ Outdoors │ 2302327 │ 4.24 │
7. │ Video ... | {"source_file": "querying-s3-bucket.md"} | [
-0.03752368688583374,
-0.009050305932760239,
-0.10278402268886566,
0.042091723531484604,
-0.008657866157591343,
0.050913140177726746,
0.07862725108861923,
-0.004299269523471594,
0.03815790265798569,
-0.026932988315820694,
0.06636977940797806,
-0.04302838072180748,
0.12213572859764099,
-0.1... |
d021113d-9e75-4917-8290-43f70ac963a1 | title: 'Using a clickhouse-local database'
sidebar_label: 'Using clickhouse-local database'
slug: /chdb/guides/clickhouse-local
description: 'Learn how to use a clickhouse-local database with chDB'
keywords: ['chdb', 'clickhouse-local']
doc_type: 'guide'
clickhouse-local
is a CLI with an embedded version of ClickH... | {"source_file": "clickhouse-local.md"} | [
0.0352361686527729,
-0.053131114691495895,
-0.06035826355218887,
0.007448786403983831,
-0.04679182916879654,
-0.012627821415662766,
0.024111395701766014,
0.030144965276122093,
-0.06795059889554977,
-0.05491790920495987,
0.021207671612501144,
-0.03408341109752655,
0.06365358084440231,
0.001... |
e2ca3c0d-4942-43b2-987a-ebd75cebfd28 | Row 1:
──────
quants: [0,9976599,2147776478,4209286886]
```
We can also insert data into this database from chDB:
```python
sess.query("""
INSERT INTO foo.randomNumbers
SELECT rand() AS number FROM numbers(10_000_000)
""")
Row 1:
──────
quants: [0,9976599,2147776478,4209286886]
```
We can then re-run the quanti... | {"source_file": "clickhouse-local.md"} | [
-0.03550894185900688,
-0.05308772251009941,
-0.058891549706459045,
0.026924272999167442,
-0.08975318819284439,
-0.05051948502659798,
0.07167791575193405,
-0.05899641290307045,
-0.00826337281614542,
0.0029046491254121065,
0.028008082881569862,
-0.009480717591941357,
0.010615105740725994,
-0... |
4d20599b-65e4-4e2e-9963-56069ff83a22 | title: 'How to query Pandas DataFrames with chDB'
sidebar_label: 'Querying Pandas'
slug: /chdb/guides/pandas
description: 'Learn how to query Pandas DataFrames with chDB'
keywords: ['chDB', 'Pandas']
show_related_blogs: true
doc_type: 'guide'
Pandas
is a popular library for data manipulation and analysis in Python... | {"source_file": "querying-pandas.md"} | [
0.04186321422457695,
-0.015455021522939205,
-0.04984642192721367,
0.010615071281790733,
0.021448681131005287,
-0.0022999129723757505,
0.0032920758239924908,
0.026585744693875313,
-0.03942481428384781,
0.020618004724383354,
0.027213910594582558,
-0.017952188849449158,
-0.015427613630890846,
... |
a682bf96-f4b5-4d6d-8695-00d7d1ea49ab | text
match_id 3943077
match_date 2024-07-15
kick_off 04:15:00.000
home_score ... | {"source_file": "querying-pandas.md"} | [
-0.0018334176857024431,
0.024311844259500504,
-0.031154463067650795,
0.023361075669527054,
0.10105183720588684,
0.07723439484834671,
-0.001394152408465743,
0.029124025255441666,
0.009207912720739841,
0.0432761088013649,
-0.029642652720212936,
-0.057821959257125854,
-0.005364251788705587,
0... |
326c8fc2-2af1-43d0-99d0-ff5b5b03a9f6 | stadium_id 5337
stadium_name Hard Rock Stadium
stadium_country_id 241
stadium_country_name United States of ... | {"source_file": "querying-pandas.md"} | [
0.0050239404663443565,
-0.03066333197057247,
-0.036242011934518814,
-0.02795487642288208,
0.06504781544208527,
0.04818614572286606,
0.031852468848228455,
0.038123443722724915,
-0.028164776042103767,
0.08684275299310684,
-0.09353179484605789,
-0.16972899436950684,
-0.03526138514280319,
0.00... |
d74432a0-4d09-4cd7-871a-765160cef840 | Next, we'll load one of the events JSON files and also add a column called
match_id
to that DataFrame:
python
response = requests.get(
"https://raw.githubusercontent.com/statsbomb/open-data/master/data/events/3943077.json"
)
events_df = pd.json_normalize(response.json(), sep='_')
events_df["match_id"] = 3943077
... | {"source_file": "querying-pandas.md"} | [
-0.04543238878250122,
0.0206715427339077,
-0.017350846901535988,
-0.0028348856139928102,
0.02254599891602993,
-0.01973695307970047,
-0.038650721311569214,
0.014011693187057972,
0.07557202875614166,
-0.021564314141869545,
0.025528185069561005,
-0.018490279093384743,
-0.07968607544898987,
0.... |
8ad397e8-57cc-4666-91e5-0a3362db34c8 | So, if we wanted to list the columns in
matches_df
, we could write the following:
python
chdb.query("""
DESCRIBE Python(matches_df)
SETTINGS describe_compact_output=1
""", "DataFrame")
text
name type
0 match_id Int64
1 match_date St... | {"source_file": "querying-pandas.md"} | [
0.06849438697099686,
0.0009763442212715745,
-0.08921486139297485,
0.05447717383503914,
0.08959339559078217,
0.06289481371641159,
-0.017387468367815018,
0.02456788346171379,
-0.07135128974914551,
0.05080785974860191,
-0.019160913303494453,
-0.020251208916306496,
-0.02179577760398388,
-0.000... |
be128842-cb80-4022-9539-2ddbcd752580 | python
chdb.query("""
SELECT pass_recipient_name, count()
FROM Python(events_df)
WHERE type_name = 'Pass' AND pass_recipient_name <> ''
GROUP BY ALL
ORDER BY count() DESC
LIMIT 10
""", "DataFrame")
text
pass_recipient_name count()
0 Davinson Sánchez Mina 76
1 Ángel Fabián Di María He... | {"source_file": "querying-pandas.md"} | [
0.07932469248771667,
0.011083784513175488,
-0.016287827864289284,
0.030492037534713745,
0.026120994240045547,
0.05697734281420708,
0.06158733740448952,
0.024227818474173546,
0.08099104464054108,
-0.02833743393421173,
0.02115618623793125,
-0.03063058853149414,
-0.0286566074937582,
0.0080844... |
cb691296-bfb3-4540-aa83-e50595d9f600 | python
sess.query("""
SELECT pass_recipient_name, count()
FROM statsbomb.events
WHERE type_name = 'Pass' AND pass_recipient_name <> ''
GROUP BY ALL
ORDER BY count() DESC
LIMIT 10
""", "DataFrame")
text
pass_recipient_name count()
0 Davinson Sánchez Mina 76
1 Ángel Fabián Di María Her... | {"source_file": "querying-pandas.md"} | [
0.04230521619319916,
0.005631273612380028,
-0.006532798521220684,
0.022442234680056572,
0.04511189088225365,
0.02959553152322769,
0.09674977511167526,
0.03683103621006012,
0.08037254214286804,
0.0032858646009117365,
0.02919168956577778,
-0.02135358937084675,
-0.001113413949497044,
-0.03032... |
884ae05c-1b15-4a65-a7e6-bda506e66215 | title: 'JupySQL and chDB'
sidebar_label: 'JupySQL'
slug: /chdb/guides/jupysql
description: 'How to install chDB for Bun'
keywords: ['chdb', 'JupySQL']
doc_type: 'guide'
import Image from '@theme/IdealImage';
import PlayersPerRank from '@site/static/images/chdb/guides/players_per_rank.png';
JupySQL
is a Python li... | {"source_file": "jupysql.md"} | [
0.04657254368066788,
0.029515858739614487,
-0.011848226189613342,
0.011684027500450611,
-0.10402685403823853,
0.08700084686279297,
0.035450052469968796,
0.10638154298067093,
-0.05490923300385475,
0.013124783523380756,
0.006236197892576456,
-0.018536163493990898,
0.13706663250923157,
-0.043... |
b1d2d4e1-e692-418e-b671-41c253bcf213 | The format of the data is a bit weird.
Let's clean that date up and use the
REPLACE
clause to return the cleaned up
ranking_date
:
python
%%sql
SELECT * REPLACE (
toDate(parseDateTime32BestEffort(toString(ranking_date))) AS ranking_date
)
FROM file('atp_rankings*.csv')
LIMIT 10
SETTINGS schema_inference_make_col... | {"source_file": "jupysql.md"} | [
0.040098659694194794,
0.010263608768582344,
0.02233918197453022,
0.014200651086866856,
-0.03199480473995209,
0.061053626239299774,
0.00759892025962472,
0.037632204592227936,
-0.06450992077589035,
0.05667435750365257,
0.012125914916396141,
-0.033753521740436554,
0.01900850608944893,
-0.0173... |
f3c449bd-2693-409e-a5f7-f5f2b92f21ce | In ClickHouse, the
Date
type only supports dates from 1970 onwards. Since the
dob
column contains dates from before 1970, we'll use the
Date32
type instead.
python
%%sql
CREATE TABLE atp.players
Engine=MergeTree
ORDER BY player_id AS
SELECT * REPLACE (
makeDate32(
toInt32OrNull(substring(toString(dob), ... | {"source_file": "jupysql.md"} | [
0.04793853312730789,
0.018167292699217796,
-0.038216106593608856,
-0.009546241723001003,
-0.06914134323596954,
0.06375116109848022,
-0.02802123688161373,
0.05749181658029556,
-0.04481814429163933,
0.03700531646609306,
0.0402684323489666,
-0.029794715344905853,
-0.010653619654476643,
0.0050... |
cb602383-f730-4dfe-8124-a91187489145 | text
+------------+-----------+-----------+------+------------+
| name_first | name_last | maxPoints | rank | date |
+------------+-----------+-----------+------+------------+
| Novak | Djokovic | 16950 | 1 | 2016-06-06 |
| Rafael | Nadal | 15390 | 1 | 2009-04-20 |
| Andy | Mur... | {"source_file": "jupysql.md"} | [
-0.033720895648002625,
-0.008062681183218956,
-0.041463255882263184,
-0.03661934658885002,
-0.030965905636548996,
0.10165824741125107,
-0.017448438331484795,
0.06668265908956528,
0.016664890572428703,
0.03557653725147247,
-0.059093065559864044,
-0.06653958559036255,
0.018934134393930435,
0... |
18498125-85f8-48b3-aec3-96979db786d6 | Querying with parameters {#querying-with-parameters}
We can also use parameters in our queries.
Parameters are just normal variables:
python
rank = 10
And then we can use the
{{variable}}
syntax in our query.
The following query finds the players who had the least number of days between when they first had a ra... | {"source_file": "jupysql.md"} | [
0.0035732754040509462,
0.07421789318323135,
0.012018304318189621,
0.013854209333658218,
-0.07204471528530121,
0.09391993284225464,
0.04007435962557793,
0.11401393264532089,
-0.06222229450941086,
-0.00727247865870595,
0.01072159968316555,
0.0016217046650126576,
0.03908735513687134,
0.087192... |
d87c5944-9ba4-47a0-8b34-b8dabbb1201c | title: 'How to query a remote ClickHouse server'
sidebar_label: 'Querying remote ClickHouse'
slug: /chdb/guides/query-remote-clickhouse
description: 'In this guide, we will learn how to query a remote ClickHouse server from chDB.'
keywords: ['chdb', 'clickhouse']
doc_type: 'guide'
In this guide, we're going to lear... | {"source_file": "query-remote-clickhouse.md"} | [
0.04408010095357895,
-0.07261449843645096,
-0.04272715747356415,
-0.008424385450780392,
-0.021765952929854393,
-0.011555133387446404,
-0.000170235987752676,
0.016228966414928436,
-0.047374043613672256,
-0.01750575751066208,
0.009036099538207054,
-0.01687316969037056,
0.006219637580215931,
... |
f8539742-c48e-4eba-9eef-4056d4d204e1 | sklearn_df = chdb.query(query, "DataFrame")
sklearn_df.sort_values(by=["x"], ascending=False).head(n=10)
```
text
x y
2392 2024-10-02 1793502
2391 2024-10-01 1924901
2390 2024-09-30 1749045
2389 2024-09-29 1177131
2388 2024-09-28 1157323
2387 2024-09-27 1688094
2386 2024-09-26 1862... | {"source_file": "query-remote-clickhouse.md"} | [
-0.011949943378567696,
-0.07623658329248428,
-0.013507985509932041,
-0.04148772731423378,
0.06452292203903198,
-0.001510782865807414,
0.02771463617682457,
0.0035231118090450764,
0.006389624904841185,
-0.01495552621781826,
0.11588557064533234,
0.07720313966274261,
-0.06782549619674683,
-0.0... |
7c38a53e-7ee9-4ff3-afd5-5a3bee65bb03 | title: 'How to query Apache Arrow with chDB'
sidebar_label: 'Querying Apache Arrow'
slug: /chdb/guides/apache-arrow
description: 'In this guide, we will learn how to query Apache Arrow tables with chDB'
keywords: ['chdb', 'Apache Arrow']
doc_type: 'guide'
Apache Arrow
is a standardized column-oriented memory forma... | {"source_file": "querying-apache-arrow.md"} | [
0.0832548588514328,
-0.07200320065021515,
-0.05227114260196686,
0.019993916153907776,
-0.06485743820667267,
0.016058171167969704,
-0.012423458509147167,
0.044419534504413605,
-0.044537730515003204,
-0.03875249624252319,
0.017418211326003075,
0.0029513395857065916,
0.03558126837015152,
-0.0... |
c22b9dd6-eb74-44f3-8998-b57434add66b | We can also count the number of rows:
python
chdb.query("SELECT count() FROM Python(arrow_table)", "DataFrame")
text
count()
0 3864546
Now, let's do something a bit more interesting.
The following query excludes the
quadkey
and
tile.*
columns and then computes the average and max values for all remaining... | {"source_file": "querying-apache-arrow.md"} | [
0.09497395157814026,
-0.029699966311454773,
-0.02526494488120079,
0.0062810759991407394,
-0.12325143814086914,
-0.00915564689785242,
-0.0020765098743140697,
0.02518576569855213,
-0.014046368189156055,
0.016743609681725502,
-0.014465708285570145,
-0.030220016837120056,
0.05193522945046425,
... |
21180563-b4be-400c-98cf-80cab34cd339 | title: 'chDB Python API Reference'
sidebar_label: 'Python API'
slug: /chdb/api/python
description: 'Complete Python API reference for chDB'
keywords: ['chdb', 'embedded', 'clickhouse-lite', 'python', 'api', 'reference']
doc_type: 'reference'
Python API Reference
Core Query Functions {#core-query-functions}
chdb... | {"source_file": "python.md"} | [
-0.0038617942482233047,
0.00048333447193726897,
-0.07077139616012573,
0.11936935037374496,
-0.07265810668468475,
-0.011174016632139683,
0.039111990481615067,
0.06216903775930405,
-0.031741078943014145,
-0.0399639755487442,
-0.023492125794291496,
-0.041821058839559555,
0.12854941189289093,
... |
339aae83-0237-4461-9745-5bee1212b3d3 | Returns
Returns the query result in the specified format:
| Return Type | Condition |
|--------------------|----------------------------------------------------------|
|
str
| For text formats like CSV, JSON |
|
pd.DataFr... | {"source_file": "python.md"} | [
0.023298949003219604,
0.02496333234012127,
-0.05037294328212738,
0.03466063365340233,
-0.02834170311689377,
0.017715970054268837,
-0.04954056441783905,
0.061445966362953186,
-0.01940833404660225,
-0.004104088060557842,
0.048834845423698425,
-0.05210728198289871,
0.018658004701137543,
-0.08... |
71d65890-159d-4e48-bd65-f8cbc0f78eaa | Syntax
python
chdb.sql(sql, output_format='CSV', path='', udf_path='')
Parameters
| Parameter | Type | Default | Description ... | {"source_file": "python.md"} | [
0.057798877358436584,
-0.004663397558033466,
-0.09482267498970032,
0.07437749952077866,
-0.12363297492265701,
0.022864587604999542,
0.06090930104255676,
0.045650236308574677,
-0.027123384177684784,
0.00042956997640430927,
0.0018548443913459778,
-0.11015938967466354,
0.04809054732322693,
-0... |
6eeb2499-f000-4c85-8fa1-c608e422ce2a | Raises
| Exception | Condition |
|---------------------------|------------------------------------------------------------------|
|
ChdbError
| If the SQL query execution fails |
|
ImportError
| If r... | {"source_file": "python.md"} | [
-0.0043043820187449455,
-0.05013507604598999,
-0.04677010700106621,
0.06914374232292175,
-0.016687652096152306,
-0.015982432290911674,
0.03872792422771454,
0.03876297175884247,
-0.042582038789987564,
-0.02597818709909916,
0.050132013857364655,
-0.0280960313975811,
0.03629251569509506,
-0.0... |
f934857b-e308-4361-bfeb-79b800f31a90 | Example
```pycon
result = chdb.query("SELECT 1 as id, 'hello' as msg", "Arrow")
df = chdb.to_df(result)
print(df)
id msg
0 1 hello
```
Connection and Session Management {#connection-session-management}
The following Session Functions are available:
chdb.connect
{#chdb-connect}
Create a... | {"source_file": "python.md"} | [
0.022534826770424843,
-0.0318622961640358,
-0.1332831233739853,
0.06740638613700867,
-0.13711918890476227,
-0.026114249601960182,
0.08637168258428574,
0.019177500158548355,
0.03329736739397049,
-0.020907774567604065,
-0.04484748840332031,
0.014650476165115833,
0.04109451547265053,
-0.04671... |
f4438a08-a7e8-4fe3-9e7b-890e8c48c2be | For a complete parameter list, see
clickhouse local --help --verbose
Returns
| Return Type | Description ... | {"source_file": "python.md"} | [
0.028133349493145943,
0.019566388800740242,
-0.029111497104167938,
0.04712020605802536,
-0.06387662142515182,
0.011585182510316372,
0.02865258976817131,
0.004473717417567968,
-0.07875914871692657,
-0.03412751108407974,
0.04615044593811035,
-0.05778631567955017,
-0.027694720774888992,
-0.05... |
97c3e352-50b1-4fae-af82-051d511cdcac | You can also use a connection string to pass in the path and other parameters.
python
class chdb.session.Session(path=None)
Examples
| Connection String | Description |
|----------------------------------------------------|---------------------------------... | {"source_file": "python.md"} | [
0.04223009571433067,
0.017484210431575775,
-0.15392759442329407,
0.09472623467445374,
-0.12516549229621887,
0.015158343128859997,
0.08934223651885986,
0.1206602230668068,
-0.032932180911302567,
-0.012448911555111408,
-0.03268643841147423,
-0.026334689930081367,
0.09003263711929321,
0.02301... |
7bbefec7-0fe5-445d-83c4-f44144b40c31 | :::warning Important
Any attempt to use the session after calling
close()
will result in an error.
:::
Examples
```pycon
session = Session("test.db")
session.query("SELECT 1")
session.close() # Explicitly close the session
```
query
{#chdb-session-session-query}
Execute a SQL query and retur... | {"source_file": "python.md"} | [
0.021201351657509804,
0.06781961023807526,
-0.12231804430484772,
0.07197071611881256,
-0.05182569846510887,
-0.02247900515794754,
0.07969103008508682,
0.06936174631118774,
0.005773323122411966,
0.006946536246687174,
-0.035238116979599,
-0.05678754672408104,
0.0034147147089242935,
-0.034192... |
d094e312-b1ee-4e2d-9501-f007d98d931d | :::note
The “Debug” format is not supported and will be automatically converted
to “CSV” with a warning.
For debugging, use connection string parameters instead.
:::
:::warning Warning
This method executes the query synchronously and loads all results into
memory. For large result sets, consider using
send_query()
... | {"source_file": "python.md"} | [
0.005716750863939524,
0.06357013434171677,
-0.10366103798151016,
0.0884861871600151,
-0.08324684202671051,
-0.0384695827960968,
0.0405622161924839,
0.08591091632843018,
0.003542459337040782,
0.025333333760499954,
0.030548477545380592,
0.014119118452072144,
0.025503158569335938,
-0.01776885... |
d58d7f91-a1c9-4089-9237-c28b96fd7ad0 | Returns
| Return Type | Description |
|-------------------|------------------------------------------------------------------------------------------------------------------------... | {"source_file": "python.md"} | [
-0.05113331601023674,
0.04828786849975586,
-0.01577206514775753,
0.025300191715359688,
-0.026352373883128166,
0.006301863584667444,
0.020808832719922066,
0.048491790890693665,
-0.007836895063519478,
-0.026433678343892097,
0.036558862775564194,
-0.07093562185764313,
0.05092862248420715,
-0.... |
e93e271f-8e8c-4161-a2e6-42e09a62799f | Syntax
python
sql(sql, fmt='CSV', udf_path='')
Parameters
| Parameter | Type | Default | Description ... | {"source_file": "python.md"} | [
0.0483112670481205,
0.005836611147969961,
-0.0685579851269722,
0.06617556512355804,
-0.10558903962373734,
-0.025437230244278908,
0.08018951863050461,
0.050658658146858215,
-0.030858565121889114,
0.013276373036205769,
0.03154696524143219,
-0.0789140909910202,
0.040355533361434937,
-0.083075... |
7c1f4fdf-7388-4dff-b6fb-5cace6b041ae | ```pycon
Query with JSON format
result = session.query("SELECT 1 as number", fmt="JSON")
print(result)
{"number": "1"}
```
```pycon
Complex query with table creation
session.query("CREATE TABLE test (id INT, name String) ENGINE = MergeTree() order by id")
session.query("INSERT INTO test VALU... | {"source_file": "python.md"} | [
-0.012311100959777832,
0.009400496259331703,
-0.09208209067583084,
0.051725056022405624,
-0.1323394775390625,
-0.021554937586188316,
0.06762654334306717,
0.05581295117735863,
0.006325758062303066,
0.015758195891976357,
0.013099764473736286,
0.04241985082626343,
0.06375376135110855,
-0.0015... |
bb236b4d-7dc7-4347-b691-ee374f1ffe18 | For a complete parameter list, see
clickhouse local --help --verbose
Returns
| Return Type | Description ... | {"source_file": "python.md"} | [
0.028133349493145943,
0.019566388800740242,
-0.029111497104167938,
0.04712020605802536,
-0.06387662142515182,
0.011585182510316372,
0.02865258976817131,
0.004473717417567968,
-0.07875914871692657,
-0.03412751108407974,
0.04615044593811035,
-0.05778631567955017,
-0.027694720774888992,
-0.05... |
88f58a26-0962-4847-8c4f-2759e7ef721d | with connect("test.db") as conn:
... conn.query("SELECT 1")
... # Connection automatically closed
```
cursor
{#chdb-state-sqlitelike-connection-cursor}
Create a
Cursor
object for executing queries.
This method creates a database cursor that provides the standard
DB-API 2.0 interface for executi... | {"source_file": "python.md"} | [
-0.04710414260625839,
-0.012430135160684586,
-0.06436832994222641,
0.08156199753284454,
-0.12137583643198013,
-0.03931552916765213,
0.057223010808229446,
0.023931700736284256,
-0.018645988777279854,
0.023056475445628166,
-0.005409883335232735,
-0.004265427589416504,
0.0408082939684391,
-0.... |
dc1342a6-a8bb-47fa-9859-7bbd3569d8e8 | Returns
| Return Type | Description |
|--------------------|--------------------------------|
|
str
| For string formats (CSV, JSON) |
|
bytes
| For Arrow format |
|
pandas.DataFrame
| For dataframe format |
|
pyarrow.Table
| For arr... | {"source_file": "python.md"} | [
0.061170537024736404,
0.005418353248387575,
-0.1054045706987381,
0.05231846496462822,
-0.0023406336549669504,
-0.04594524949789047,
0.012825749814510345,
0.05660735443234444,
-0.02888563647866249,
-0.02370479144155979,
0.030923081561923027,
0.02826506458222866,
-0.006630327086895704,
-0.01... |
6b45f83a-b44b-4962-889a-5406166d2ced | Returns
| Return Type | Description |
|-------------------|--------------------------------... | {"source_file": "python.md"} | [
-0.0052984775975346565,
0.08059202134609222,
0.03870628401637077,
0.03293995186686516,
-0.07898212224245071,
0.03403903543949127,
0.04770667850971222,
0.014872120693325996,
0.037789005786180496,
-0.05088052526116371,
0.021917130798101425,
-0.06212566792964935,
-0.013598302379250526,
-0.052... |
8aeb14a2-bf2e-4d96-8ff6-29ec79a3ee6a | column_names
{#chdb-state-sqlitelike-cursor-column_names}
Return a list of column names from the last executed query.
This method returns the column names from the most recently executed
SELECT query. The names are returned in the same order as they appear
in the result set.
Syntax
python
column_names() → list... | {"source_file": "python.md"} | [
0.01648537442088127,
0.047289229929447174,
-0.0602538138628006,
0.04641889035701752,
-0.026687683537602425,
-0.04558838531374931,
0.04835846647620201,
0.03548196703195572,
0.014583117328584194,
0.0017456625355407596,
0.059229329228401184,
-0.00707605853676796,
-0.019057869911193848,
-0.125... |
f9c5a112-5511-4208-b132-4bf5ecf458a3 | Currently, only name and type_code are provided, with other fields set to None.
Returns
| Return Type | Description |
|-------------|-------------|
|
list
| List of 7-tuples describing each column, or empty list if no SELECT query has been executed |
:::note
This follows the DB-API 2.0 specification for cursor.... | {"source_file": "python.md"} | [
-0.05698929354548454,
0.02629716321825981,
-0.07305163890123367,
0.02604202926158905,
-0.06004408746957779,
-0.07721473276615143,
0.0175807923078537,
0.007481585256755352,
-0.044411689043045044,
-0.015144904144108295,
0.01723591610789299,
-0.023131173104047775,
0.0003928901569452137,
-0.11... |
023c52ec-b2ff-4fb8-9db5-afa2813896d8 | Returns:
| Return Type | Description |
|-------------|-------------|
|
tuple
| Tuple containing all remaining row tuples from the result set. Returns empty tuple if no rows are available |
:::warning Warning
This method loads all remaining rows into memory at once. For large
result sets, consider using
fetchmany... | {"source_file": "python.md"} | [
-0.0015061385929584503,
0.02688155695796013,
-0.040870290249586105,
0.019460536539554596,
-0.05967549607157707,
-0.04788140952587128,
0.031227516010403633,
0.031795646995306015,
-0.09535272419452667,
-0.012494541704654694,
0.034318991005420685,
0.010804621502757072,
0.04291476681828499,
-0... |
5e15ce10-8a17-4da9-9c72-978830b91b6f | :::note
This method follows DB-API 2.0 specifications. Column values are
automatically converted to appropriate Python types based on
ClickHouse column types.
:::
Examples
```pycon
cursor = conn.cursor()
cursor.execute("SELECT id, name FROM users")
row = cursor.fetchone()
while row is not None:
... user... | {"source_file": "python.md"} | [
-0.0004886544775217772,
-0.016168376430869102,
-0.06071095913648605,
0.029470784589648247,
-0.12493061274290085,
-0.018258025869727135,
0.0591963529586792,
0.03143322095274925,
-0.071678027510643,
-0.03188103437423706,
-0.005333802662789822,
-0.015325205400586128,
0.06946918368339539,
-0.0... |
2307aeba-303f-4c88-b51b-fa376ec57dcd | Raises
| Exception | Condition |
|---------------|-------------------------------------------------|
|
ImportError
| If pyarrow or pandas packages are not installed |
:::note
This function uses multi-threading for the Arrow to Pandas conversion
to improve performance on l... | {"source_file": "python.md"} | [
0.04624912515282631,
-0.06721131503582001,
-0.054304298013448715,
0.0031457433942705393,
-0.03113471157848835,
-0.05583524703979492,
-0.016703762114048004,
0.019823655486106873,
-0.06534618139266968,
-0.022071365267038345,
0.04316224902868271,
0.03339936584234238,
-0.0009853907395154238,
-... |
64a67374-e020-4eeb-892e-5d108db732ba | This function converts the input to bytes type for use with binary
database fields, following the DB-API 2.0 specification.
Syntax
python
chdb.dbapi.Binary(x)
Parameters
| Parameter | Type | Description |
|------------|-------|---------------------------------|
|
x
| - | Input... | {"source_file": "python.md"} | [
0.009582816623151302,
0.010443675331771374,
-0.08671539276838303,
0.03268714249134064,
-0.09742598235607147,
-0.05636138468980789,
0.03814636543393135,
0.0005732105346396565,
-0.058080438524484634,
-0.03573901951313019,
-0.08719991892576218,
-0.08410216867923737,
0.10345574468374252,
-0.01... |
384ea2f2-521f-4cb0-bdbc-1735b6ba64fc | Closes the underlying chDB connection and marks this connection as closed.
Subsequent operations on this connection will raise an Error.
Syntax
python
close()
Raises
| Exception | Condition |
|--------------------------------------|-------------------------------... | {"source_file": "python.md"} | [
-0.034045107662677765,
-0.017155112698674202,
-0.043683793395757675,
0.054497066885232925,
-0.10164541006088257,
-0.059341784566640854,
0.030468512326478958,
-0.024628575891256332,
0.030854126438498497,
0.037873707711696625,
0.01768646202981472,
-0.06443097442388535,
0.059291284531354904,
... |
33303a3e-692e-417a-bf17-94a523e2dfac | query
{#dbapi-query}
Execute a SQL query directly and return raw results.
This method bypasses the cursor interface and executes queries directly.
For standard DB-API usage, prefer using cursor() method.
Syntax
python
query(sql, fmt='CSV')
Parameters:
| Parameter | Type | Default | Description ... | {"source_file": "python.md"} | [
-0.041249144822359085,
0.03336047753691673,
-0.08131381869316101,
0.06544096767902374,
-0.09849657118320465,
-0.071687713265419,
0.02365410514175892,
0.032034747302532196,
-0.02148045413196087,
-0.03624138608574867,
0.0077418177388608456,
-0.08073535561561584,
0.11224034428596497,
-0.10367... |
523e04bd-42d9-4fbc-b4f2-392458091087 | Do not create Cursor instances directly. Use
Connection.cursor()
instead.
python
class chdb.dbapi.cursors.Cursor(connection)
| Variable | Type | Description |
|-------------------|-------|-------------------------------------------------------------|
|
de... | {"source_file": "python.md"} | [
0.012076172046363354,
-0.034512683749198914,
-0.07130543887615204,
0.015253953635692596,
-0.14585784077644348,
-0.023543208837509155,
0.03321864828467369,
0.03499603271484375,
-0.050012681633234024,
0.014217356219887733,
0.010428289882838726,
-0.04157785698771477,
0.11804893612861633,
-0.1... |
5c1f54bc-feaa-4575-8fb0-a1817851d923 | Syntax
python
execute(query, args=None)
Parameters
| Parameter | Type | Default | Description |
|------------|-----------------|------------|------------------------------------|
|
query
| str |
required
| SQL query to execute |
|
args
|... | {"source_file": "python.md"} | [
-0.00009329172462457791,
0.018594320863485336,
0.01853363588452339,
0.09218963235616684,
-0.11094168573617935,
-0.085005983710289,
0.0828920528292656,
0.007372608873993158,
-0.07975833863019943,
-0.032406777143478394,
0.0018706565024331212,
-0.06398778408765793,
0.10141795873641968,
-0.111... |
867e4228-29d9-4b0d-9308-b957ee6ef2a7 | users_data = [
... {'id': 1, 'name': 'Alice'},
... {'id': 2, 'name': 'Bob'}
... ]
cur.executemany(
... "INSERT INTO users VALUES (%(id)s, %(name)s)",
... users_data
... )
```
:::note
This method improves performance for multiple-row INSERT and UPDATE operations
by optimizing the query execution ... | {"source_file": "python.md"} | [
-0.007554670330137014,
0.0559835359454155,
0.011394369415938854,
0.03602908179163933,
-0.09911871701478958,
-0.060208819806575775,
0.004159801173955202,
0.006437450181692839,
-0.07928331941366196,
0.002446887083351612,
0.08470343798398972,
-0.05930500105023384,
0.10937108099460602,
-0.1241... |
a2b93c66-973f-4c2b-83ad-b3893f37276b | Example
```pycon
cursor.execute("SELECT id, name FROM users LIMIT 3")
row = cursor.fetchone()
print(row) # (1, 'Alice')
row = cursor.fetchone()
print(row) # (2, 'Bob')
```
max_stmt_length = 1024000
{#max-stmt-length}
Max statement size which
executemany()
generates.
Default value is 1024000... | {"source_file": "python.md"} | [
-0.02547820843756199,
-0.011105394922196865,
-0.06907651573419571,
0.047021619975566864,
-0.11079291999340057,
-0.09637417644262314,
0.054148562252521515,
0.07721880078315735,
-0.0628315731883049,
-0.03819776698946953,
0.025696352124214172,
-0.00868234597146511,
0.08225181698799133,
-0.123... |
1c4cfcb7-f71c-4eca-9bfc-a8ead98db631 | Error Classes {#error-classes}
Exception classes for chdb database operations.
This module provides a complete hierarchy of exception classes for handling
database-related errors in chdb, following the Python Database API Specification v2.0.
The exception hierarchy is structured as follows:
default
StandardErro... | {"source_file": "python.md"} | [
-0.006015187595039606,
0.017059912905097008,
-0.02316146530210972,
0.06142289936542511,
-0.04931717365980148,
-0.04232587292790413,
-0.00784290675073862,
0.07201298326253891,
-0.08692808449268341,
-0.023928748443722725,
-0.00984626542776823,
-0.05401550605893135,
0.11720214039087296,
-0.01... |
6cda93f1-c5b1-4dae-aae6-55d8611824b9 | Invalid data format for column type
Raises
| Exception | Condition |
|-----------|-----------|
|
DataError
| When data validation or processing fails |
Examples
```pycon
Division by zero in SQL
cursor.execute("SELECT 1/0")
DataError: Division by zero
```
```pycon
Invalid date forma... | {"source_file": "python.md"} | [
-0.0360477976500988,
-0.008425775915384293,
-0.02169014699757099,
0.025046948343515396,
-0.039689794182777405,
-0.042709216475486755,
-0.02476726472377777,
0.06976175308227539,
-0.07263033092021942,
0.002262918744236231,
0.059381332248449326,
-0.040954042226076126,
0.10252410173416138,
-0.... |
2cc27b9e-b9c6-4cbe-a024-03adab742e96 | exception
chdb.dbapi.err.InterfaceError
{#chdb-dbapi-err-interfaceerror}
Bases:
Error
Exception raised for errors that are related to the database interface rather than the database itself.
This exception is raised when there are problems with the database interface
implementation, such as:
Invalid connec... | {"source_file": "python.md"} | [
-0.03850410506129265,
0.0054543279111385345,
-0.015561972744762897,
0.046354152262210846,
-0.07760657370090485,
-0.009042483754456043,
-0.0018888245103880763,
0.07154889404773712,
-0.06928479671478271,
-0.010570893064141273,
0.013851991854608059,
-0.1086684837937355,
0.13749799132347107,
-... |
5f0395b1-5e77-4309-8d21-465dcb456e06 | Examples
```pycon
Transaction rollback on non-transactional connection
connection.rollback()
NotSupportedError: Transactions are not supported
```
```pycon
Using unsupported SQL syntax
cursor.execute("SELECT * FROM table WITH (NOLOCK)")
NotSupportedError: WITH clause not supported in this ... | {"source_file": "python.md"} | [
-0.06840597838163376,
0.003996450453996658,
-0.09196857362985611,
0.038926683366298676,
-0.04445945471525192,
-0.023640844970941544,
0.01970013789832592,
0.03736705705523491,
-0.04378049820661545,
0.00790480338037014,
0.09178613871335983,
0.059532564133405685,
0.10561101883649826,
-0.01508... |
261aa0ab-ba8d-4da8-90ba-b349fc08d4c4 | ```pycon
SQL syntax error
cursor.execute("SELCT * FROM users")
ProgrammingError: You have an error in your SQL syntax
```
```pycon
Wrong parameter count
cursor.execute("INSERT INTO users (name, age) VALUES (%s)", ('John',))
ProgrammingError: Column count doesn't match value count
```
... | {"source_file": "python.md"} | [
-0.009440629743039608,
-0.013860524632036686,
-0.04622981324791908,
0.032485511153936386,
-0.0921768844127655,
0.0009022600133903325,
0.045412641018629074,
0.09779788553714752,
-0.05808212608098984,
-0.017825789749622345,
0.07266199588775635,
-0.05122467875480652,
0.15296834707260132,
-0.0... |
5782d791-48f3-4da3-b002-fcab2e26ad6d | Type Constants {#type-constants}
chdb.dbapi.STRING = frozenset({247, 253, 254})
{#string-type}
Extended frozenset for DB-API 2.0 type comparison.
This class extends frozenset to support DB-API 2.0 type comparison semantics.
It allows for flexible type checking where individual items can be compared
against the s... | {"source_file": "python.md"} | [
0.00039438632666133344,
0.01672104187309742,
-0.047131143510341644,
0.04816793277859688,
-0.03575773537158966,
-0.026542747393250465,
0.025086132809519768,
0.0501868762075901,
-0.05626466125249863,
-0.04354533925652504,
-0.015984538942575455,
-0.015032009221613407,
0.020406821742653847,
-0... |
1b830b5b-088c-4818-8790-1725a0d91adc | This is used for type constants like STRING, BINARY, NUMBER, etc. to enable
comparisons like “field_type == STRING” where field_type is a single type value.
Examples
```pycon
string_types = DBAPISet([FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING])
FIELD_TYPE.STRING == string_types # Returns True
FIELD_TYPE.INT ... | {"source_file": "python.md"} | [
-0.033806703984737396,
0.02109895460307598,
-0.04717836156487465,
0.068489208817482,
-0.04057744890451431,
-0.025615757331252098,
0.04038405790925026,
0.06229034438729286,
-0.03935282304883003,
-0.0475778691470623,
-0.016361840069293976,
-0.006063074339181185,
0.008160470984876156,
-0.0255... |
99f56927-081f-4e3c-91be-eebd3a8957fe | This is used for type constants like STRING, BINARY, NUMBER, etc. to enable
comparisons like “field_type == STRING” where field_type is a single type value.
Examples
```pycon
string_types = DBAPISet([FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING])
FIELD_TYPE.STRING == string_types # Returns True
FIELD_TYPE.INT ... | {"source_file": "python.md"} | [
0.010179124772548676,
0.046324826776981354,
-0.018420707434415817,
0.05028526112437248,
-0.06127801537513733,
-0.04643147066235542,
0.04731494560837746,
0.027780571952462196,
-0.028006786480545998,
-0.07792527973651886,
-0.015004167333245277,
-0.049872707575559616,
0.055682916194200516,
-0... |
12a22e78-20d7-4f4c-b816-2110cf3b9590 | :::warning Warning
- Always close cursors and connections to avoid resource leaks
- Large result sets should be processed in batches
- Parameter binding syntax follows format style:
%s
:::
User-Defined Functions (UDF) {#user-defined-functions}
User-defined functions module for chDB.
This module provides functio... | {"source_file": "python.md"} | [
0.016433950513601303,
0.01240190677344799,
-0.06512058526277542,
0.07834526151418686,
-0.0809219479560852,
-0.0007389571401290596,
0.07442539930343628,
0.08502207696437836,
-0.06422046571969986,
-0.008095018565654755,
-0.026032207533717155,
-0.11853164434432983,
0.05100052431225777,
-0.079... |
3a5593a5-1999-4521-8efa-7ec224c145ac | chdb.utils.convert_to_columnar
{#convert-to-columnar}
Converts a list of dictionaries into a columnar format.
This function takes a list of dictionaries and converts it into a dictionary
where each key corresponds to a column and each value is a list of column values.
Missing values in the dictionaries are represe... | {"source_file": "python.md"} | [
0.02205747179687023,
0.037775833159685135,
-0.05929868668317795,
0.03330864757299423,
-0.07926852256059647,
-0.008092218078672886,
0.02557099238038063,
-0.0012594832805916667,
-0.03740572929382324,
-0.02772008627653122,
0.010015244595706463,
-0.09473288804292679,
-0.002840102184563875,
-0.... |
d438b591-b640-4fa6-b775-11cd6984dfc8 | chdb.utils.infer_data_type
{#infer-data-type}
Infers the most suitable data type for a list of values.
This function examines a list of values and determines the most appropriate
data type that can represent all the values in the list. It considers integer,
unsigned integer, decimal, and float types, and defaults ... | {"source_file": "python.md"} | [
-0.004540944937616587,
0.03399030864238739,
-0.026175059378147125,
0.02896898426115513,
-0.034985121339559555,
0.02464410476386547,
0.08570896834135056,
0.012440909631550312,
-0.06149754300713539,
-0.043074123561382294,
-0.05421649292111397,
-0.07255832105875015,
-0.00014805907267145813,
0... |
53dcce28-20e9-45a9-be68-5975e8bb2e43 | Returns
| Return Type | Description |
|---------------|----------------------------------------------------------------------------|
|
List[tuple]
| A list of tuples, each containing a column name and its inferred data type |
Abstract Base Classes {... | {"source_file": "python.md"} | [
-0.011354572139680386,
0.04376417025923729,
-0.06392970681190491,
0.01046671625226736,
-0.05575359985232353,
-0.018899518996477127,
0.0673031136393547,
0.013845359906554222,
-0.10695018619298935,
-0.060353729873895645,
-0.03096039406955242,
-0.07357272505760193,
-0.001934194820933044,
0.01... |
b3cd795e-6535-4368-a1ae-4aea863db6b9 | The exception message typically contains detailed error information
from ClickHouse, including syntax errors, type mismatches, missing
tables/columns, and other query execution issues.
Variables
| Variable | Type | Description |
|-----------|-------|------------... | {"source_file": "python.md"} | [
0.03327624872326851,
-0.015308617614209652,
-0.04169879108667374,
0.0682348906993866,
-0.009703642688691616,
-0.03529352322220802,
0.007821562699973583,
0.049501627683639526,
-0.08927188068628311,
-0.03801601752638817,
0.0683378279209137,
-0.049988120794296265,
0.11376293748617172,
-0.0576... |
d6027191-7a55-4fc2-a466-b6078a1f8055 | title: 'SQL Reference'
sidebar_label: 'SQL reference'
slug: /chdb/reference/sql-reference
description: 'SQL Reference for chDB'
keywords: ['chdb', 'sql reference']
doc_type: 'reference'
chdb supports the same SQL syntax, statements, engines and functions as ClickHouse:
| Topic |
|------------... | {"source_file": "sql-reference.md"} | [
-0.005672273691743612,
-0.055848393589258194,
-0.08726225048303604,
0.06801985204219818,
-0.025384865701198578,
0.05365912988781929,
0.0799950510263443,
0.038096461445093155,
-0.05409858375787735,
-0.05541525036096573,
-0.02866632118821144,
-0.012659496627748013,
0.06458619982004166,
-0.09... |
9f8aa838-af85-438b-a9b3-c96f28a3b051 | title: 'Data Formats'
sidebar_label: 'Data formats'
slug: /chdb/reference/data-formats
description: 'Data Formats for chDB'
keywords: ['chdb', 'data formats']
doc_type: 'reference'
When it comes to data formats, chDB is 100% feature compatible with ClickHouse.
Input formats are used to parse the data provided to ... | {"source_file": "data-formats.md"} | [
0.02150585502386093,
-0.08557353168725967,
-0.11822322010993958,
0.022616229951381683,
-0.023982331156730652,
0.0008586602052673697,
-0.02657501958310604,
0.011179574765264988,
-0.05627387762069702,
-0.03542749583721161,
0.00999442022293806,
0.02097783237695694,
0.04649888351559639,
-0.030... |
1d98277f-85e1-4196-a8da-dc0be0f23ed1 | | Format | Input | Output |
|---------------------------------|-------|--------|
| TabSeparated | ✔ | ✔ |
| TabSeparatedRaw | ✔ | ✔ |
| TabSeparatedWithNames | ✔ | ✔ |
| TabSeparatedWithNamesAndTypes | ✔ | ✔ |
| ... | {"source_file": "data-formats.md"} | [
0.033987194299697876,
0.003845985746011138,
-0.12560728192329407,
0.06080031022429466,
-0.03857637196779251,
0.0497436597943306,
0.021435454487800598,
0.07262492179870605,
-0.04813940450549126,
0.005998415872454643,
0.02460470236837864,
-0.09924189001321793,
0.11806336045265198,
-0.1026577... |
f3f7008c-5bfa-47f4-8138-832b12b7cc3a | | PrettySpaceNoEscapes | ✗ | ✔ |
| PrettySpaceMonoBlock | ✗ | ✔ |
| PrettySpaceNoEscapesMonoBlock | ✗ | ✔ |
| Prometheus | ✗ | ✔ |
| Protobuf | ✔ | ✔ |
| ProtobufSingle | ✔ | ✔ |
| ... | {"source_file": "data-formats.md"} | [
-0.048366837203502655,
-0.0321604385972023,
-0.059126801788806915,
-0.09385927021503448,
-0.04310258850455284,
-0.06178932636976242,
0.011923559941351414,
0.013162526302039623,
-0.0755077600479126,
0.07290013879537582,
0.034201543778181076,
-0.12440939992666245,
0.0649028867483139,
-0.0230... |
3e3a3524-5d7e-4a29-a2b4-bfb5f2ce6d8b | For further information and examples, see
ClickHouse formats for input and output data
. | {"source_file": "data-formats.md"} | [
0.01809600368142128,
-0.07165859639644623,
-0.13498957455158234,
-0.029558178037405014,
-0.04663218930363655,
-0.0037073015701025724,
-0.07141613215208054,
0.013061827048659325,
-0.062361858785152435,
-0.02899964340031147,
0.03664017841219902,
0.026538869366049767,
0.03260474279522896,
-0.... |
5ea6c569-323f-4551-8a66-738ee32c0e47 | title: 'chDB Technical Reference'
slug: /chdb/reference
description: 'Data Formats for chDB'
keywords: ['chdb', 'data formats']
doc_type: 'reference'
| Reference page |
|----------------------|
|
Data Formats
|
|
SQL Reference
| | {"source_file": "index.md"} | [
0.018618330359458923,
-0.017486589029431343,
-0.05637313053011894,
0.02409919537603855,
-0.05389309301972389,
0.06572137773036957,
0.028826765716075897,
0.040269020944833755,
-0.044060636311769485,
-0.023005466908216476,
-0.043418895453214645,
-0.03569836914539337,
0.07136798650026321,
-0.... |
5f71ca53-3584-4128-aa0f-ac25d9974faf | slug: /faq/general/ne-tormozit
title: 'What does “не тормозит” mean?'
toc_hidden: true
toc_priority: 11
description: 'This page explains what "Не тормозит" means'
keywords: ['Yandex']
doc_type: 'reference'
What does "Не тормозит" mean? {#what-does-ne-tormozit-mean}
We often get this question when people see vinta... | {"source_file": "ne-tormozit.md"} | [
-0.06242720037698746,
0.02438083291053772,
-0.021796442568302155,
0.04016844928264618,
-0.00191282550804317,
-0.027170566841959953,
0.10152766108512878,
-0.012401202693581581,
0.03176281601190567,
-0.04410238936543465,
0.04316660761833191,
0.07331661880016327,
0.055151745676994324,
0.02921... |
ef6eed79-34f4-4f4c-a0a1-37bf446c4538 | slug: /faq/general/olap
title: 'What is OLAP?'
toc_hidden: true
toc_priority: 100
description: 'An explainer on what Online Analytical Processing is'
keywords: ['OLAP']
doc_type: 'reference'
What Is OLAP? {#what-is-olap}
OLAP
stands for Online Analytical Processing. It is a broad term that can be looked at from ... | {"source_file": "olap.md"} | [
-0.04851805418729782,
-0.031645841896533966,
-0.10664249211549759,
0.05006612464785576,
0.006870245095342398,
-0.0823553130030632,
0.017669904977083206,
0.04382869973778725,
0.032937414944171906,
0.03358638286590576,
-0.0414830818772316,
0.05509742349386215,
0.07464670389890671,
-0.0412570... |
7da5a914-b619-4854-a9b3-e498cc570b88 | Even if a DBMS started as a pure OLAP or pure OLTP, they are forced to move towards that HTAP direction to keep up with their competition. And ClickHouse is no exception, initially, it has been designed as
fast-as-possible OLAP system
and it still does not have full-fledged transaction support, but some features like... | {"source_file": "olap.md"} | [
-0.0073633091524243355,
-0.043382566422224045,
-0.08077719807624817,
0.05642823502421379,
0.0077899424359202385,
-0.07394484430551529,
-0.03363001346588135,
0.03272582218050957,
0.08312829583883286,
0.04481353983283043,
0.022411318495869637,
0.11476408690214157,
0.030791740864515305,
-0.04... |
8fb7d0a2-db04-4085-8051-370f3a456a80 | title: 'What does "ClickHouse" mean?'
toc_hidden: true
toc_priority: 10
slug: /faq/general/dbms-naming
description: 'Learn about What does "ClickHouse" mean?'
doc_type: 'reference'
keywords: ['ClickHouse name', 'clickstream', 'data warehouse', 'database naming', 'ClickHouse history']
What does "ClickHouse" mean? {#... | {"source_file": "dbms-naming.md"} | [
-0.08117790520191193,
-0.09317956119775772,
-0.01677660457789898,
0.014075486920773983,
-0.024887079373002052,
-0.01308247447013855,
0.10096081346273422,
-0.05684325844049454,
-0.010165859945118427,
-0.03595297411084175,
0.06761106103658676,
-0.013341316021978855,
0.05148584395647049,
-0.0... |
31e0abfc-5ec2-4964-8656-62e99611b32f | slug: /faq/general/who-is-using-clickhouse
title: 'Who is using ClickHouse?'
toc_hidden: true
toc_priority: 9
description: 'Describes who is using ClickHouse'
keywords: ['customer']
doc_type: 'reference'
Who is using ClickHouse? {#who-is-using-clickhouse}
Being an open-source product makes this question not so st... | {"source_file": "who-is-using-clickhouse.md"} | [
0.0006289260927587748,
-0.06609072536230087,
-0.053013838827610016,
-0.07356775552034378,
0.02052239142358303,
-0.03512350842356682,
0.025204427540302277,
-0.021698880940675735,
-0.024837570264935493,
-0.06498391181230545,
0.03195766732096672,
-0.019225193187594414,
-0.046503689140081406,
... |
df5e9ab2-7b0b-434c-9d63-cc7d9836d5c4 | slug: /faq/general/
sidebar_position: 1
sidebar_label: 'General questions about ClickHouse'
keywords: ['faq', 'questions', 'what is']
title: 'General Questions About ClickHouse'
description: 'Index page listing general questions about ClickHouse'
doc_type: 'landing-page'
General questions about ClickHouse
What ... | {"source_file": "index.md"} | [
0.02651510015130043,
-0.05556318536400795,
-0.06946249306201935,
0.023175744339823723,
-0.025104666128754616,
-0.03986387327313423,
0.006443173158913851,
0.024649299681186676,
-0.09637568145990372,
-0.003722512861713767,
0.02507210709154606,
0.02912253700196743,
0.034988295286893845,
-0.04... |
3523696a-5d16-44f3-b238-a802d28ba33c | slug: /faq/general/mapreduce
title: 'Why not use something like MapReduce?'
toc_hidden: true
toc_priority: 110
description: 'This page explains why you would use ClickHouse over MapReduce'
keywords: ['MapReduce']
doc_type: 'reference'
Why not use something like MapReduce? {#why-not-use-something-like-mapreduce}
W... | {"source_file": "mapreduce.md"} | [
-0.01488339714705944,
-0.00845594983547926,
-0.021375609561800957,
-0.022842006757855415,
-0.06262435019016266,
-0.013167946599423885,
-0.04211772605776787,
0.0636967346072197,
-0.01418220903724432,
0.10654915869235992,
-0.017574798315763474,
0.09419544041156769,
0.046477098017930984,
-0.0... |
430f1120-dfda-4153-9a62-f1dbd518876a | slug: /faq/general/columnar-database
title: 'What is a columnar database?'
toc_hidden: true
toc_priority: 101
description: 'This page describes what a columnar database is'
keywords: ['columnar database', 'column-oriented database', 'OLAP database', 'analytical database', 'data warehousing']
doc_type: 'reference'
i... | {"source_file": "columnar-database.md"} | [
-0.04870033264160156,
-0.050083812326192856,
-0.17744074761867523,
0.05126519501209259,
0.008260396309196949,
-0.0964447557926178,
0.004743673838675022,
0.024467511102557182,
0.018536152318120003,
0.08319102227687836,
0.01077863946557045,
0.09072602540254593,
0.07738907635211945,
-0.068213... |
b5ab9d13-57fd-4335-be18-c767788ffb15 | slug: /faq/integration/
sidebar_position: 1
sidebar_label: 'Integrating ClickHouse with other systems'
keywords: ['clickhouse', 'faq', 'questions', 'integrations']
title: 'Questions about integrating ClickHouse and other systems'
description: 'Landing page listing questions related to integrating ClickHouse with other ... | {"source_file": "index.md"} | [
-0.00009110523387789726,
-0.08455648273229599,
-0.1227845624089241,
-0.014573675580322742,
-0.05692604184150696,
-0.05327505245804787,
-0.003769313683733344,
0.01646575890481472,
-0.10244423896074295,
-0.04754114896059036,
0.022193333134055138,
-0.0002921807754319161,
0.06238355115056038,
... |
7ff91d1f-a4cc-40ee-816e-2a3d6d3f3899 | slug: /faq/integration/oracle-odbc
title: 'What if I have a problem with encodings when using Oracle via ODBC?'
toc_hidden: true
toc_priority: 20
description: 'This page provides guidance on what to do if you have a problem with encodings when using Oracle via ODBC'
doc_type: 'guide'
keywords: ['oracle', 'odbc', 'encod... | {"source_file": "oracle-odbc.md"} | [
-0.017792247235774994,
-0.11017797142267227,
-0.08544784039258957,
0.005684586241841316,
-0.019468313083052635,
-0.05249840393662453,
0.053024470806121826,
0.022897901013493538,
-0.022058412432670593,
-0.007170130033046007,
-0.012220659293234348,
-0.03746657073497772,
-0.021805360913276672,
... |
b7cad2d1-9116-416d-a892-87b7c55cad43 | slug: /faq/integration/json-import
title: 'How to import JSON into ClickHouse?'
toc_hidden: true
toc_priority: 11
description: 'This page shows you how to import JSON into ClickHouse'
keywords: ['JSON import', 'JSONEachRow format', 'data import', 'JSON ingestion', 'data formats']
doc_type: 'guide'
How to Import JSO... | {"source_file": "json-import.md"} | [
-0.048550888895988464,
-0.04838163033127785,
-0.0681261196732521,
0.016465019434690475,
-0.04606111720204353,
-0.009922546334564686,
-0.041654109954833984,
0.005743261426687241,
-0.0726374089717865,
-0.017449766397476196,
0.021364949643611908,
-0.03177807480096817,
0.0467008501291275,
0.03... |
4ce28e19-d44a-4b70-ab20-41f7c52ea6cf | slug: /faq/operations/production
title: 'Which ClickHouse version to use in production?'
toc_hidden: true
toc_priority: 10
description: 'This page provides guidance on which ClickHouse version to use in production'
doc_type: 'guide'
keywords: ['production', 'deployment', 'versions', 'best practices', 'upgrade strategy'... | {"source_file": "production.md"} | [
-0.015320926904678345,
-0.06434056162834167,
0.05174433812499046,
-0.030948173254728317,
0.09656595438718796,
-0.007259075529873371,
-0.041700612753629684,
-0.01444858405739069,
-0.02047143131494522,
0.010526569560170174,
0.005299500655382872,
0.0651126280426979,
-0.07869589328765869,
0.02... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.