Simple http api tunnel for duckdb cli with AWS S3, local database and remote requests
288
Parquet-api is a simple library compatible with AWS S3 that uses DuckDB and Node.js to build a docker api that you can make sql queries using http requests.
You can create local tables and connect to remote parquet files as DuckDB allow you.
Local parquet files need to be read/write without concurrency, so if you use LOCAL_DB as 1 I don't recommend to use this script in production because requests can be slow if is not in an fast ssd. Memory DB (LOCAL_DB as 0) can be up to 50% faster.
Make sure to not open 8080 port as public without SSL.
To run, ou can execute:
docker run -d -p 0.0.0.0:8080:8080 liveseo/parquet-api
You can also add AWS S3 keys to make it connected with keys S3_REGION, S3_KEY and S3_SECRET:
docker run -d -p 0.0.0.0:8080:8080 -e S3_SECRET=mysecret123 -e S3_KEY=mykey -e S3_REGION=sa-east-1 liveseo/parquet-api
If you want to use a simple authorization token, set TOKEN env and set it as header on every request:
docker run -d -p 0.0.0.0:8080:8080 -e TOKEN=mysecrettoken123 liveseo/parquet-api
If you want to use memory database with more workers for fast response set LOCAL_DB env as 0 and set WORKERS to any number higher than 1:
docker run -d -p 0.0.0.0:8080:8080 -e WORKERS=10 -e LOCAL_DB=0 liveseo/parquet-api
Now, you can make requests in http://localhost:8080/?q=SELECT 2 as abc
The response is JSON, like:
[ { "abc": 2 } ]
| ENVIRONMENT VARIABLE | Description | Default value |
|---|---|---|
| TOKEN | Used for headers authentication. If set, send header Token:yourtoken | - |
| DBFILE | Location of duckdb local database. Only used if LOCAL_DB is 1 | /data/myduck.db |
| MAX_BUFFER | Size in MB for child node process of duckdb. | 64 |
| LOCAL_DB | 1 to use local persistent db file or 0 to use only memory | 1 |
| WORKERS | Total of workers. Only used if LOCAL_DB is 0 | 1 |
| S3_REGION | S3 region. Example: sa-east-1 | - |
| S3_KEY | S3 key. Example: mys3key | - |
| S3_SECRET | S3 secret. Example: mys3secret | - |
Author: liveSEO
Content type
Image
Digest
sha256:6b84d38c7…
Size
361.8 MB
Last updated
over 3 years ago
docker pull liveseo/parquet-api