这是indexloc提供的服务,不要输入任何密码
Skip to content

yusufozturk/duckdb-extension-httpserver

 
 

Repository files navigation

DuckDB HTTP Server Extension

This very experimental extension spawns an HTTP Server from within DuckDB serving query requests.
The extension goal is to replace the functionality currently offered by our project Quackpipe

Screenshot

Extension Functions

  • httpserve_start(host, port)
  • httpserve_stop()

API Endpoints

  • /query
  • /health

Usage

Start the HTTP server providing the host and port parameters

D SELECT httpserve_start('0.0.0.0',9999);
┌─────────────────────────────────────┐
│  httpserve_start('0.0.0.0', 9999)   │
│               varchar               │
├─────────────────────────────────────┤
│ HTTP server started on 0.0.0.0:9999 │
└─────────────────────────────────────┘

Query

Query the endpoint using curl GET/POST requests

# curl -X POST -d "SELECT 42 as answer" http://localhost:9999/query
answer
INTEGER
[ Rows: 1]
42

Build steps

Now to build the extension, run:

make

The main binaries that will be built are:

./build/release/duckdb
./build/release/test/unittest
./build/release/extension/<extension_name>/<extension_name>.duckdb_extension
  • duckdb is the binary for the duckdb shell with the extension code automatically loaded.
  • unittest is the test runner of duckdb. Again, the extension is already linked into the binary.
  • <extension_name>.duckdb_extension is the loadable binary as it would be distributed.

Running the extension

To run the extension code, simply start the shell with ./build/release/duckdb. This shell will have the extension pre-loaded.

D SELECT httpserve_start('0.0.0.0',9999);
┌─────────────────────────────────────┐
│  httpserve_start('0.0.0.0', 9999)   │
│               varchar               │
├─────────────────────────────────────┤
│ HTTP server started on 0.0.0.0:9999 │
└─────────────────────────────────────┘

Running the tests

Different tests can be created for DuckDB extensions. The primary way of testing DuckDB extensions should be the SQL tests in ./test/sql. These SQL tests can be run using:

make test

About

DuckDB HTTP Server Community Extension

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 40.9%
  • Shell 25.1%
  • Python 22.0%
  • CMake 10.2%
  • Makefile 1.8%