A Python-based server that runs a local DuckDB instance and support queries over Web Sockets or HTTP, returning data in either Apache Arrow or JSON format.
Note: This package provides a local DuckDB server. To instead use DuckDB-WASM in the browser, use the wasmConnector in the mosaic-core package.
We recommend running the server in an isolated environment with uvx. For example, to directly run the server, use:
uvx duckdb-serverAlternatively, you can install the server with pip install duckdb-server. Then you can start the server with duckdb-server.
We use uv to manage our development setup.
Start the server with uv run duckdb-server. The server will not restart when the code changes.
Start the server in development with pnpm dev. The server restarts when you change the code.
Run uv run ruff check --fix and uv run ruff format to lint the code.
To run the tests, use uv run pytest.
To set up a local certificate for SSL, use https://github.com/FiloSottile/mkcert.
The server supports queries via HTTP GET and POST, and WebSockets. The GET endpoint is useful for debugging. For example, you can query it with this url.
Each endpoint takes a JSON object with a command in the type. The server supports the following commands.
Executes the SQL query in the sql field.
Executes the SQL query in the sql field and returns the result in Apache Arrow format.
Executes the SQL query in the sql field and returns the result in JSON format.
Run the build with uv build. Then publish with uvx twine upload --skip-existing ../../dist/*. We publish using tokens so when asked, set the username to __token__ and then use your token as the password. Alternatively, create a .pypirc file.