A lightweight client-server library fluently extending DuckDB's httpserver setup to Python
Project description
DuckBridge
Lightweight Python library enabling fully pythonic interfacing with the DuckDB extension httpserver (extension developed by @quackscience).
What is duckbridge?
DuckDB's httpserver extension turns databases into HTTP OLAP servers; however, setup and access require unix commands and SQL in order to properly set up authentication, install the extension, and communicate.
duckbridge spans this gap, providing a way to natively use httpserver with full pythonic scripting. The DuckDBServer class acts as the bridge operator, connecting to the database, initializing httpserver, and setting authentication values and read/write privileges. DuckDBClient provides a tidy handler which stores client-side authentication and endpoint information, ensuring one-factor authentication by way of knowledge while returning information as a Pandas DataFrame.
How do I use duckbridge?
Duckbridge is split into two main portions: DuckbridgeServer, which handles extension installation/activation, database connection, and client request processing, and DuckbridgeClient, which formats and sends requests to an assumed endpoint, unmarshalling returned data into a convenient format (currently only a Pandas DataFrame).
Examples of how to set up a server or client can be found in more depth at , a repository of tutorials that is constantly being updated.
If you have a use case that you would like to have considered, please and it will be addressed!
Quick start copy-and-paste
####################
### Server setup ###
####################
from duckbridge import *
import os
my_ssh_key_auth : str = "mySuperSecretSSHString"
ssh_userpass_auth : str = "username:password" # !!!The colon is mandatory!!!
my_host : str = "127.0.0.1" # Replace with 0.0.0.0 for public ip access
my_port : int = 8080
bridge : DuckbridgeServer = DuckbridgeServer()
# Assumes readonly permissions and that the database doesn't have `httpserver` installed yet
# If an empty string is provided for auth_info, then no security will be used
bridge.start(os.cwd() + "/path/to/db.db", host=my_host, port=my_port, auth_info=my_ssh_key_auth)
####################
### Client setup ###
####################
from duckbridge import *
import pandas as pd
my_username : str = "username"
my_password : str = "password"
client : DuckbridgeClient = DuckbridgeClient(my_host, my_port, my_username, my_password, my_ssh_key_auth)
data : pd.DataFrame = client.execute("Select * from concept limit 3;", auth="ssh")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file duckbridge-0.4.1.tar.gz.
File metadata
- Download URL: duckbridge-0.4.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
661984755354b9665050d9bac6c346793fc1f93c550d79c074308e5a0f1d6092
|
|
| MD5 |
34ed0e45c9a1ec037c7c065dc4241f00
|
|
| BLAKE2b-256 |
1894a32917e0198f4715c732ffd9409d9711691a388eb850257038e5b86555f9
|
File details
Details for the file duckbridge-0.4.1-py3-none-any.whl.
File metadata
- Download URL: duckbridge-0.4.1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac70661a842af1b8cbd8aa18f47c1e26e451b4cc1fa095a5640894a2f082167a
|
|
| MD5 |
49e0acb2c45c6b7bf082121e68deed3b
|
|
| BLAKE2b-256 |
c59c2aeb62d677e742e994397b3145bd93a683bb504ccb5a0a0ebed41e70b50b
|