/chdb-server

Standalone chDB server by chdb-go

Primary LanguageHTMLApache License 2.0Apache-2.0

chDB Server

This project is a Go-based web server that integrates with the chDB-go and provides a web interface for executing database queries. It embeds the static file play.html directly within the binary for easy distribution and deployment.

chDB Server

Features

  • Query Execution: Allows users to execute queries against a CHDB database.
  • Session Management: Persists the database connection across multiple queries.
  • Static Content: Serves a static HTML file (play.html) embedded within the executable.

Prerequisites

Before you start, ensure you have the following installed:

  • Go 1.16 or higher
  • libchdb
curl -sL https://lib.chdb.io | bash

Installation

  1. Go Install
go install github.com/auxten/chdb-server@latest
$GOPATH/bin/chdb-server
  1. Build from source
git clone https://github.com/auxten/chdb-server.git
make build
./chdb-server

Session Path

You can configure the server by setting the following environment variables before running the server:

  • DATA_PATH: Specifies the directory path for CHDB session data. Defaults to .chdb_data if not set.

Usage

Open your browser and navigate to http://localhost:8123 to start querying any data.

Create a new database

CREATE TABLE users (uid Int16, name String, age Int16) ENGINE=Memory;

INSERT INTO users VALUES (1231, 'John', 33);
INSERT INTO users VALUES (6666, 'Ksenia', 48);
INSERT INTO users VALUES (8888, 'Alice', 50);

SELECT * FROM users;

Query remote parquet data

SELECT RegionID, SUM(AdvEngineID), COUNT(*) AS c, AVG(ResolutionWidth), COUNT(DISTINCT UserID)
                        FROM url('https://datasets.clickhouse.com/hits_compatible/athena_partitioned/hits_0.parquet') GROUP BY RegionID ORDER BY c DESC LIMIT 10