jupysql
Better SQL in Jupyter
What it is and what it does
JupySQL is a Jupyter/IPython extension that lets you write and execute SQL queries directly in notebook cells using `%sql` (single-line) and `%%sql` (multi-line) magic commands. It acts as a SQL client for Jupyter, bridging the gap between notebook Python code and external databases. The package depends on sqlalchemy for database abstraction, sqlparse for SQL parsing, jinja2 for templating, and several IPython utilities to integrate seamlessly into the notebook environment.
The package is designed to make exploratory data analysis and SQL development more natural in notebooks by eliminating the need to switch between tools. It supports multiple database backends (PostgreSQL, MySQL, DuckDB, and others via SQLAlchemy) and offers features like Pandas integration for downstream Python processing, SQL composition helpers, and memory-efficient plotting of large result sets. It is currently in Alpha status (Development Status 3), indicating active development but potential API changes.
Use it for:
- Run ad-hoc SQL queries against production or analytical databases directly from a Jupyter notebook without leaving your analysis environment.
- Compose and debug complex SQL queries using templating and composition features, then pass results to Pandas for further Python-based analysis.
- Visualize query results without loading entire datasets into memory by using the built-in plotting capabilities.
- Prototype data pipelines in notebooks by mixing SQL queries with Python logic in a single, reproducible document.
- Explore DuckDB or other SQLAlchemy-supported databases interactively without writing boilerplate connection code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds SQL execution to Jupyter and IPython notebooks via `%sql` and `%%sql` magic commands, letting you query databases directly in cells and integrate results with Python.
Yes, if you work regularly in Jupyter and need to query databases. Low install friction, active maintenance, permissive license, and no known vulnerabilities make it a straightforward addition. The Alpha status means the API may shift, but 848 stars and ongoing commits suggest it is stable enough for exploratory and development work. Not necessary if you already have a preferred SQL IDE or if your workflow rarely involves database queries from notebooks.
Install
jupysql on PyPI
pip
pip install jupysqluv
uv add jupysqlpoetry
poetry add jupysqlInstalling jupysql
Before you install
Low install friction with a pure-Python wheel. Active maintenance (last commit 2026-06-29) and 848 repository stars suggest ongoing community use. Ten runtime dependencies are manageable and well-established (sqlalchemy, ipython, jinja2, sqlparse, prettytable, sqlglot, and others).
License in practice
Permissive Apache license allows commercial and private use without restriction, making it suitable for any deployment context.
Quickstart
pip install jupysql
In Jupyter:
%load_ext sql
%sql SELECT * FROM table_name
Requires Jupyter or IPython environment; a database connection string must be configured before queries will execute.
Verify before relying
- Whether all advertised integrations (Pandas, DuckDB, plotting) are included in version 0.11.1 or require additional setup.
- Minimum Python version and compatibility with recent Jupyter/IPython releases.
- Performance characteristics when querying large datasets despite the advertised memory-efficient plotting.
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 10 — prettytable, ipython, sqlalchemy, sqlparse, ipython-genutils, jinja2, sqlglot, importlib-metadata, jupysql-plugin, ploomber-core |
| Maintenance | actively maintained — 507 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 156,088/month — #10,793 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: jupysql-0.11.1-py3-none-any.whl
Keywords: database, ipython, postgresql, mysql, duckdb
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
ipython-sqlAdds SQL magic commands to IPython and Jupyter…
permissive · top 15,000 on PyPI
jupysql-pluginA JupyterLab 4 extension that integrates…
permissive · top 15,000 on PyPI
bigquery-magicsProvides IPython magic commands to query Google…
permissive · top 15,000 on PyPI
pgspecialExecutes PostgreSQL meta-commands (backslash…
permissive · top 15,000 on PyPI
duckdb-engineA SQLAlchemy driver that enables you to use…
permissive · top 5,000 on PyPI
fastlitefastlite wraps sqlite-utils to provide…
permissive · top 15,000 on PyPI
emr-notebooks-magicsProvides iPython magics for Amazon EMR…
permissive · top 5,000 on PyPI
jupyter-dashJupyter Dash lets you develop and run Plotly…
permissive · top 15,000 on PyPI
duckdbDuckDB is an in-process SQL database engine…
permissive · top 1,000 on PyPI
ipythonIPython is an enhanced interactive Python shell…
permissive · top 1,000 on PyPI