Public
Edited
Feb 6, 2023
Insert cell
Insert cell
DuckDBClient
Insert cell
gaiadb = DuckDBClient.of({
gaia: FileAttachment("gaia.arrow")
})
Insert cell
gaiadb
SELECT * FROM gaia USING SAMPLE 5%
Insert cell
// ตั้งชื่อผลลัพธ์ของ database query ข้างบน แล้วมาดู
stars
Insert cell
stars[0].ra
Insert cell
stars
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Inputs.table(stars) // ประหยัดกว่า sql cell หน่อย
Insert cell
stocks = DuckDBClient.of({
aapl: FileAttachment("aapl.csv")
})
Insert cell
// ใช้ sql markup ได้
stocks.sql`SELECT Open, Close, Volume FROM aapl WHERE Volume > ${100_000_000}`
Insert cell
// ใช้ query() ก็ได้ แต่แยก template, var
stocks.query(
"SELECT Open, Close, Volume FROM aapl WHERE Volume > ?",
[200_000_000]
)
Insert cell
// ถ้าเอาอันแรก ใช้ queryRow
maxaapl = stocks.queryRow("SELECT Date, Open, Close, Volume FROM aapl ORDER BY Volume DESC LIMIT 1")
Insert cell
maxaapl.Volume
Insert cell
Insert cell
db = DuckDBClient.of({
test: [{id:1, title:'a quick'},
{id:2, title:'brown fox'},
{id:3, title:'jumps over'},
{id:4, title:'the lazy dog'}
]
})
Insert cell
db
SELECT * FROM test
Insert cell
db.describeTables()
Insert cell
rows = db.sql`SELECT * FROM test`
Insert cell
db.query("PRAGMA create_fts_index('test', 'id', 'title');")
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more