Knitr engine for DuckDB CLI
Details
Supported chunk options:
dbPath to a DuckDB database file. Defaults to
":memory:".sessionSession name. If it already exists, it is reused. Otherwise a new session is created. When omitted, the last used session is reused (or a new one is created automatically).
modeDuckDB output mode (e.g.,
"table","markdown","csv"). Sends.mode <value>before executing the chunk's SQL.timeoutMaximum milliseconds to wait for output. Defaults to
30000.ansiControls handling of ANSI escape codes in output.
TRUEpreserves them,FALSE(default) strips them, and"html"converts them to HTML markup viacli::ansi_html().
Examples
opts = c(
knitr::opts_chunk$get(),
list(code = "SELECT 42 AS answer;", engine = "duckdb", label = "demo")
)
cat(eng_duckdb(opts))
#> SELECT 42 AS answer;
#> ## ┌────────┐
#> ## │ answer │
#> ## │ int32 │
#> ## ├────────┤
#> ## │ 42 │
#> ## └────────┘
duckknit_kill_all_sessions()
