JupySQL

0.11.1 · active · verified Fri Apr 17

JupySQL (version 0.11.1) enhances SQL interaction within Jupyter notebooks, allowing users to connect to various databases and execute queries directly using IPython magic commands. It supports advanced features like variable interpolation, caching, and data visualization. The project is actively maintained with frequent releases, typically every few weeks.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to load the JupySQL extension, connect to an in-memory SQLite database, create a table, insert data, and execute a simple SQL query using the `%sql` and `%%sql` magic commands.

# Load the JupySQL extension
%load_ext sql

# Connect to an in-memory SQLite database
%sql sqlite:///:memory:

# Create a table and insert some data
%%sql
CREATE TABLE employees (
    id INTEGER PRIMARY KEY,
    name TEXT,
    department TEXT,
    salary INTEGER
);
INSERT INTO employees (id, name, department, salary) VALUES
    (1, 'Alice', 'Sales', 50000),
    (2, 'Bob', 'Marketing', 60000),
    (3, 'Charlie', 'Sales', 55000);

# Query the data
%sql SELECT * FROM employees WHERE department = 'Sales';

view raw JSON →