quack-kernels provides Jupyter Kernels for DuckDB, enabling users to interact with DuckDB databases directly from Jupyter notebooks using either SQL or Python. It currently stands at version 0.3.9 and is actively maintained with releases tied to DuckDB and Jupyter ecosystem updates.
pip install quack-kernelsVerified import paths — ran on the pinned version, not inferred.
After installing with `pip install quack-kernels`, launch Jupyter Lab or Notebook (`jupyter lab`). Create a new notebook and select either the 'DuckDB SQL' or 'DuckDB Python' kernel. The provided Python code demonstrates interaction with DuckDB using the 'DuckDB Python' kernel, where direct `duckdb` module calls are supported.
Always install `quack-kernels` in a fresh environment or ensure your `duckdb` version aligns with the `quack-kernels` requirements. If issues arise, try upgrading/downgrading `duckdb` or `quack-kernels` to a known working pair.
Run `python -m ipykernel install --user --name duckdb_sql --display-name 'DuckDB SQL'` and `python -m ipykernel install --user --name duckdb_python --display-name 'DuckDB Python'` (though `quack-kernels` handles this, manual intervention might be needed for unusual environments), or reinstall `quack-kernels` and restart Jupyter.
For persistent data, connect to a file-based DuckDB database: `con = duckdb.connect(database='my_database.duckdb')`. The file will persist across kernel restarts and sessions.
Select the 'DuckDB Python' kernel for general Python code that uses `duckdb` module. Select the 'DuckDB SQL' kernel for running raw SQL queries directly in cells. Use Jupyter magic commands (`%%sql` etc.) in Python notebooks if you need to mix languages.