SQL formatting#

To enable SQL formatting, install jupysql:

pip install jupysql --upgrade

Then, a “Format SQL” button will appear in JupyterLab:


Try it out#

To try it, click on the 🚀 button at the top of this page, then click on Binder:


Then, wait for JupyterLab to load. Once it loads, click on “Format SQL” and you’ll see that the SQL cell below is formatted!

from pathlib import Path
from urllib.request import urlretrieve

if not Path("penguins.csv").is_file():
%load_ext sql
%sql duckdb://
select * from penguins.csv where island = 'Torgersen' limit 3
*  duckdb://
species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex
Adelie Torgersen 39.1 18.7 181 3750 MALE
Adelie Torgersen 39.5 17.4 186 3800 FEMALE
Adelie Torgersen 40.3 18.0 195 3250 FEMALE