{"id":3787,"library":"quack-kernels","title":"Quack Kernels for Jupyter","description":"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.","status":"active","version":"0.3.9","language":"en","source_language":"en","source_url":"https://github.com/duckdb/quack-kernels","tags":["jupyter","duckdb","kernel","sql","data-science","database"],"install":[{"cmd":"pip install quack-kernels","lang":"bash","label":"Install core library and kernels"}],"dependencies":[{"reason":"Core database engine for the kernels.","package":"duckdb","optional":false},{"reason":"Required for running Jupyter Notebooks or Lab where kernels are used.","package":"jupyterlab","optional":false},{"reason":"Used for data interchange and display within the Python kernel.","package":"pandas","optional":false},{"reason":"Used for efficient data transfer with DuckDB.","package":"pyarrow","optional":false}],"imports":[{"note":"Primarily used for programmatic kernel management or customization. End-users typically interact by selecting kernels in Jupyter, not through direct Python imports in their notebooks.","wrong":"from quack_kernels import DuckDBSQLKernel","symbol":"DuckDBSQLKernel","correct":"from quack_kernels.duckdb_sql import DuckDBSQLKernel"},{"note":"Similar to DuckDBSQLKernel, this is for programmatic interaction; standard usage is via Jupyter kernel selection.","symbol":"DuckDBPythonKernel","correct":"from quack_kernels.duckdb_python import DuckDBPythonKernel"}],"quickstart":{"code":"import duckdb\nimport pandas as pd\n\n# This code runs within a Jupyter notebook using the 'DuckDB Python' kernel.\n# The 'quack-kernels' library provides the infrastructure for this.\n\n# Connect to an in-memory DuckDB database\ncon = duckdb.connect(database=':memory:', read_only=False)\n\n# Create a table and insert data using SQL\ncon.execute(\"CREATE TABLE my_data (id INTEGER, name VARCHAR);\")\ncon.execute(\"INSERT INTO my_data VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie');\")\n\n# Query the table and fetch results into a pandas DataFrame\nresult_df = con.execute(\"SELECT * FROM my_data WHERE id > 1;\").fetchdf()\n\nprint(\"Fetched data from DuckDB (as pandas DataFrame):\")\nprint(result_df)\n\n# Close the connection (important for file-based DBs, optional for :memory:)\ncon.close()","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"DuckDB version compatibility: `quack-kernels` is closely tied to specific `duckdb` versions. Ensure your `duckdb` installation is compatible with the `quack-kernels` version to avoid unexpected behavior or errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"Kernel not appearing in Jupyter: After installation, if the 'DuckDB SQL' or 'DuckDB Python' kernels do not appear in Jupyter, the kernelspecs might not have been installed correctly.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"In-memory database persistence: When using `duckdb.connect(':memory:')`, the database and all its data are lost if the kernel is restarted or the notebook session ends. This is a common pitfall for data analysis.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"Misunderstanding kernel purpose (SQL vs. Python): Users sometimes try to run Python code in the 'DuckDB SQL' kernel or raw SQL in the 'DuckDB Python' kernel without magic commands.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}