An open API service indexing awesome lists of open source software.

https://github.com/cowsdb/cowsdb

CowsDB: Serverless OLAP Engine API and 100% ClickHouse alternative for CI and HTTP Services
https://github.com/cowsdb/cowsdb

chdb chdb-server clickhouse clickhouse-alternative clickhouse-server cowsdb embedded-sql-database olap-engine serverless

Last synced: about 2 months ago
JSON representation

CowsDB: Serverless OLAP Engine API and 100% ClickHouse alternative for CI and HTTP Services

Awesome Lists containing this project

README

          

image

# CowsDB
[![CowsDB SQL Bench](https://github.com/cowsdb/cowsdb/actions/workflows/test.yml/badge.svg)](https://github.com/cowsdb/cowsdb/actions/workflows/test.yml)

> CowsDB prentends to be ClickHouse and can be used with any ClickHouse client for serverless ops

## โœจ Features

- **๐Ÿ”Œ ClickHouse HTTP API Compatibility** - Full HTTP API support on port 8123
- **โšก Native Protocol Support** - Binary protocol support on port 9000
- **๐Ÿ“Š Multiple Output Formats** - TSV, JSON, CSV, and Native binary formats


## ๐Ÿš€ Quick Start
```
docker run --rm -p 8123:8123 -p 9000:9000 ghcr.io/cowsdb/cowsdb:latest
```

## ๐Ÿ”ง Configuration

### Environment Variables

| Variable | Default | Description |
|----------|---------|-------------|
| `HOST` | `0.0.0.0` | Server host address |
| `PORT` | `8123` | HTTP API port |
| `NATIVE_PORT` | `9000` | Native protocol port |
| `SESSION_TTL` | `3600` | Session timeout in seconds |

### Example Configuration
```bash
export HOST=0.0.0.0
export PORT=8123
export NATIVE_PORT=9000
export SESSION_TTL=7200
python main.py
```

## ๐Ÿ“– Usage

### HTTP API (Port 8123)

#### Basic Query
```bash
curl -G --data-urlencode "query=SELECT version(), now()" http://test:test@localhost:8123
```

#### POST Queries
```bash
curl -X POST --data "SELECT 1 as num, 'hello' as str" http://test:test@localhost:8123
```

#### Ping Endpoint
```bash
curl http://localhost:8123/ping
# Returns: Ok.
```

### Native Protocol (Port 9000)

#### Using clickhouse-driver
```python
from clickhouse_driver import Client

# Connect to CowsDB
client = Client('localhost', port=9000)

# Execute queries
result = client.execute('SELECT version(), now()')
print(result)

# Query with parameters
result = client.execute('SELECT %(num)s as number', {'num': 42})
print(result)
```

#### Using clickhouse-client
```bash
clickhouse-client --host localhost --port 9000 --query "SELECT version(), now()"
```

## ๐Ÿงช Testing

### Run the Complete Test Suite
```bash
# From project root
python run_tests.py tests

# Or directly
python test/test_suite.py

# Or using the CI script
bash test/run_tests.sh
```

This will test:
- โœ… HTTP API functionality
- โœ… Native protocol handshake and queries
- โœ… Multiple data types (Integer, String, Float, DateTime)
- โœ… Different output formats (TSV, JSON, CSV)
- โœ… Session management and authentication
- โœ… Error handling

### Environment Setup
```bash
# Production environment variables
export HOST=0.0.0.0
export PORT=8123
export NATIVE_PORT=9000

# Start with Gunicorn
gunicorn -w 4 -b 0.0.0.0:8123 main:app
```

## ๐Ÿค Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## ๐Ÿ“„ License

CowsDB is licensed under the AGPLv3 license and is NOT affiliated in any way with ClickHouse Inc.