PitchHut
Log in / Sign up
duckdb-api
39 views
Effortlessly execute SQL queries with DuckDB and Hono.js
Pitch

Seamlessly run DuckDB behind a Hono.js API within a Docker container, enabling you to execute SQL queries effortlessly. With endpoints for standard and streaming queries, you can integrate powerful data solutions without hassle. Configure authentication and AWS support easily, making your data access secure and efficient.

Description

The duckdb-api project enables seamless integration of DuckDB within a Hono.js API framework, all securely encapsulated in a Docker container. This powerful combination allows developers to perform SQL queries efficiently while leveraging the robust features of DuckDB, and effortlessly handle data streaming.

Key Features

  • Lightweight Docker Solution: Deploy your API using Docker with ease and flexibility.
  • Dynamic SQL Query Execution: Utilize the POST /query endpoint to send SQL commands and retrieve results in JSON format.
  • Streaming Data: With POST /streaming-query, you can stream Arrow formatted data directly to your client, ideal for handling large datasets.

Configuration

The API is easily configurable using environment variables:

  • PORT: Specify the port for the API (default: 3000).
  • Basic Authentication: Secure your API with USERNAME and PASSWORD.
  • AWS Integration: Connect with AWS S3 by providing AWS_REGION, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY for enhanced data management.

Usage Examples

To make the most out of this API, here are some quick command examples:

Execute Simple Query

curl -X POST http://localhost:3000/query -H "Content-Type: application/json" -d '{"query": "SELECT 1;"}'

Stream Data from Parquet File

curl --location 'localhost:3000/streaming-query' \
  --header 'Content-Type: application/json' \
  --data '{
    "query": "SELECT * FROM 'https://shell.duckdb.org/data/tpch/0_01/parquet/orders.parquet' LIMIT 100"
  }' \
  --output /tmp/result.arrow

With duckdb-api, you can harness the capability of DuckDB right behind a modern API, facilitating powerful data querying experiences in your applications.