基于 quarto
测试 DuckDB
功能。
以下所有代码可以复制到 jupyter notebook 中执行。
安装依赖
!pip install duckdb==0.10.0 jupysql --quiet
[notice] A new release of pip is available: 23.2.1 -> 24.0
[notice] To update, run: pip install --upgrade pip
基础配置
import duckdb
conn = duckdb.connect()
jupysql 配置
%load_ext sql
%config SqlMagic.autopandas = True
%config SqlMagic.feedback = 0
%config SqlMagic.displaycon = True
%config SqlMagic.displaylimit = 10
%sql conn --alias duckdb-native
演示数据
参考 Jupyter Notebooks
%%sql --save short_trips --no-execute
SELECT *
FROM 'https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-01.parquet'
WHERE trip_distance < 6.3
Skipping execution...
%sqlplot histogram --table short_trips --column trip_distance --bins 10 --with short_trips