Quack Kernels for Jupyter

0.3.9 · active · verified Sat Apr 11

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.

Warnings

Install

Imports

Quickstart

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.

import duckdb
import pandas as pd

# This code runs within a Jupyter notebook using the 'DuckDB Python' kernel.
# The 'quack-kernels' library provides the infrastructure for this.

# Connect to an in-memory DuckDB database
con = duckdb.connect(database=':memory:', read_only=False)

# Create a table and insert data using SQL
con.execute("CREATE TABLE my_data (id INTEGER, name VARCHAR);")
con.execute("INSERT INTO my_data VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie');")

# Query the table and fetch results into a pandas DataFrame
result_df = con.execute("SELECT * FROM my_data WHERE id > 1;").fetchdf()

print("Fetched data from DuckDB (as pandas DataFrame):")
print(result_df)

# Close the connection (important for file-based DBs, optional for :memory:)
con.close()

view raw JSON →