# Wrapping a Serverless ClickHouse pt.3

[![](https://avatars.githubusercontent.com/u/132536224?s=400&v=4 align="left")](https://chdb.io)

Meet **chdb**: the in-memory OLAP Engine based on [ClickHouse](https://github.com/clickhouse/clickhouse)

Built on the solid foundations of ClickHouse, [chdb](https://chdb.io) is a lightning-fast OLAP engine designed for in-memory processing and native binding into popular languages.

*Think of DuckDB, but Clickhouse powered.*

In a nutshell, [chdb](https://chdb.io) offers all of the ClickHouse columnar functions to retrieve, transform, and analyze local and remote data using SQL, easily interacting with popular data formats such as Parquet, Arrow, CSV, and JSON. Distributed as a library, it requires no server installation and offers native bindings for popular programming languages to run native speed queries from [Python, Go, Rust, Node and Bun](https://chdb.dev).

**How fast is it?** Check out the [ClickBench benchmark](https://shorturl.at/wzHV4) for a detailed answer 😎

### Features

* In-process SQL OLAP Engine, powered by ClickHouse
    
* No need to install ClickHouse
    
* Minimized data copy from C++ to Python with [Python memoryview](https://docs.python.org/3/c-api/memoryview.html)
    
* Input&Output support Parquet, CSV, JSON, Arrow, ORC and 60+[more](https://clickhouse.com/docs/en/interfaces/formats) formats
    

[![](https://github.com/chdb-io/chdb/raw/pybind/docs/_static/arch-chdb.png align="left")](https://chdb.dev)

### Backstory

Many have tried and *(mostly)* failed at binding a library around ClickHouse, and if you follow our blog you know we've been building our own musl clickhouse-local version too, but our friend [Auxten](https://auxten.com/) managed to patiently puzzle together a working binding builder and library wrapper, opening the way for [chdb](https://chdb.io) and [libchdb](https://github.com/metrico/libchdb) to be created.

*Well done Auxten, and thanks for letting us join the chdb development group!*

[![/head.png](https://auxten.com/head.png align="left")](https://auxten.com)

### Python

**chdb** is available as a module for **Python 3.7+** on macOS and Linux *(amd64/aarch64)*

```bash
pip install chdb
```

*That's it.* You can immediately start using **chdb** from your Python code:

```python
import chdb
res = chdb.query('select version()', 'Pretty'); print(res.data())
```

You can use chdb to instantly access and analyze any *Parquet*, *CSV, Dataframe* or any other [supported format](https://clickhouse.com/docs/en/interfaces/formats) file locally or using any S3-compatible object storage:

```python
# Query local files in any format
res = chdb.query('select * from file("data.parquet", Parquet)', 'JSON'); print(res.data())

# With large data result use get_memview() to avoid extra data copy.
res = chdb.query('select * from file("data.csv", CSV)', 'CSV');  print(str(res.get_memview().tobytes()))

# Use Dataframe format natively from python
chdb.query('select * from file("data.parquet", Parquet)', 'Dataframe')
```

You can also invoke chdb from CLI using Python. Let's query a remote CH server:

```bash
python3 -m chdb "select count(*) from remoteSecure('play.clickhouse.com:9440','default.covid','play','play')"
```

*If you love ClickHouse and want to use its powerful functions.... sky's the limit!*

### More Bindings: Go, Rust, Node, Bun

*Not into Python? No worries! chdb bindings are available for many languages:*

* [chdb-go](https://github.com/chdb-io/chdb-go)
    
* [chdb-node](https://github.com/chdb-io/chdb-node)
    
* [chdb-bun](https://github.com/chdb-io/chdb-bun)
    
* [chdb-rust](https://github.com/chdb-io/chdb-rust)
    

Before using the bindings, you will have to install [libchdb](https://github.com/metrico/libchdb) on your system using the provided **deb** or **rpm** packages *(currently only for Linux/amd64 and modern GLIBC)*

The bindings invoke the library for full-speed processing even when using NodeJS. *Using ClickHouse from within your application has never been easier!* ⚡⚡⚡

### Public Demo

You can use **chdb** to build anything, including serverless query processors. Here's our [public demo](https://github.com/chdb-io/chdb-server) running on a 100% free *1xCPU/256MB RAM* instance on [fly.io](https://fly.io) and pretending to be a Clickhouse HTTP server including the *"Play"* user interface:

<iframe src="https://chdb.fly.dev/?user=default#U0VMRUNUCiAgICB0b3duLAogICAgZGlzdHJpY3QsCiAgICBjb3VudCgpIEFTIGMsCiAgICByb3VuZChhdmcocHJpY2UpKSBBUyBwcmljZQpGUk9NIHVybCgnaHR0cHM6Ly9kYXRhc2V0cy1kb2N1bWVudGF0aW9uLnMzLmV1LXdlc3QtMy5hbWF6b25hd3MuY29tL2hvdXNlX3BhcnF1ZXQvaG91c2VfMC5wYXJxdWV0JykKR1JPVVAgQlkKICAgIHRvd24sCiAgICBkaXN0cmljdApMSU1JVCAxMA==" width="100%" height="500"></iframe>

<center>☝️☝️☝️ This is a Live demo, not just an image. Click RUN ☝️☝️☝️</center>

### Project Status

**chdb** is still *experimental and under heavy development* but already fully functional. The library size is not irrelevant at ~100MB compressed (~380MB uncompressed) but its optimized for low memory usage and operating at native speed with a minimal footprint of just ~100MB, allowing it to run in places where ClickHouse cannot.

*There's so much more on the horizon for chdb and the ClickHouse community!*

[![](https://cdn.hashnode.com/res/hashnode/image/upload/v1684058425132/bbb41489-1997-4661-bf18-2fc66deb9409.png align="left")](https://chdb.dev)

Are you skilled in C/C++ or interested in helping evolve the Go/Rust/Node bindings? Join us and help with the development of **chdb** at [https://github.com/chdb-io](https://github.com/chdb-io)
