ipython-sql
RDBMS access via IPython
What it is and what it does
ipython-sql is a magic command extension for IPython and Jupyter notebooks that lets you write and execute SQL queries directly in notebook cells. It connects to any database supported by SQLAlchemy—PostgreSQL, MySQL, SQLite, Oracle, and others—using standard SQLAlchemy connection strings. Once connected, you can issue queries with %sql (single-line) or %%sql (multi-line) magic, and results are returned as objects you can iterate over, access by column name, or convert to Pandas DataFrames.
The package handles multiple simultaneous database connections, supports variable substitution and bind parameters, and lets you capture query results into Python variables for further analysis. It's designed for exploratory data work and ad-hoc querying in notebooks, where switching between SQL and Python would otherwise require separate tools or boilerplate connection code.
Use it for:
- Exploratory data analysis in Jupyter: query a database and immediately plot or analyze results in the same notebook.
- Prototyping SQL queries interactively without leaving the notebook environment.
- Teaching SQL or databases in a classroom setting where students can write and test queries live.
- Combining SQL queries with Python data processing: fetch data, transform it, and visualize it in one workflow.
- Quick ad-hoc reporting from a database without setting up a separate reporting tool.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds SQL magic commands to IPython and Jupyter notebooks, letting you query databases directly from cells using SQLAlchemy connection strings.
Yes, if you work regularly in Jupyter or IPython and need to query databases interactively. The low install friction and permissive license make it a low-risk addition. However, the dormant maintenance status (last release over a year ago, Alpha classification) means you should verify compatibility with your Python and IPython versions before relying on it for production workflows. No known security vulnerabilities.
Install
ipython-sql on PyPI
pip
pip install ipython-sqluv
uv add ipython-sqlpoetry
poetry add ipython-sqlInstalling ipython-sql
Before you install
Low install friction with a pure-Python wheel and six runtime dependencies. Maintenance is dormant—last release was 2023-02-27, over a year ago, though the repository remains active with 1797 stars and no archived status.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install ipython-sql
In IPython or Jupyter:
%load_ext sql
%%sql postgresql://user:password@localhost/dbname
SELECT * FROM table LIMIT 5;
Requires IPython or Jupyter to be installed and running; database driver for your target database (e.g., psycopg2 for PostgreSQL) must be installed separately.
Verify before relying
- Whether the package works with modern Python versions (3.9+) given its Alpha status and dormant maintenance.
- Current compatibility with recent IPython and SQLAlchemy versions.
- Whether all six runtime dependencies are actively maintained and free of vulnerabilities.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — prettytable, ipython, sqlalchemy, sqlparse, six, ipython-genutils |
| Maintenance | dormant — 1,264 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 387,691/month — #7,043 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ipython_sql-0.5.0-py3-none-any.whl
Keywords: database, ipython, postgresql, mysql
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
jupysqlAdds SQL execution to Jupyter and IPython…
permissive · top 15,000 on PyPI
recordsRecords provides a lightweight SQL query…
permissive · top 15,000 on PyPI
fastlitefastlite wraps sqlite-utils to provide…
permissive · top 15,000 on PyPI
pangresUpserts pandas DataFrames into PostgreSQL,…
permissive · top 15,000 on PyPI
pandasqlpandasql lets you query pandas DataFrames using…
unclear · top 5,000 on PyPI
sqlalchemy-jdbcapiSQLAlchemy dialect for JDBC and ODBC database…
permissive · top 15,000 on PyPI
databasesProvides async database access for PostgreSQL,…
permissive · top 5,000 on PyPI
mssqlWraps SQLAlchemy and pyodbc to simplify…
permissive · top 15,000 on PyPI
cloud-sql-python-connectorProvides IAM-based authentication and encrypted…
permissive · top 5,000 on PyPI
dsnparseParses DSN (Data Source Name) connection URL…
permissive · top 15,000 on PyPI