Using DuckDB CLI in Emacs
I've been using DuckDB for quick analysis of CSV files and as a local data warehouse. The stock CLI has tab-completion and syntax highlighting in the terminal, which is nice, but before long I want a real editor, preferably with multiline prompt history cycling. DataGrip's DuckDB support is fine, but for quick analysis, I'd rather just grab emacs (as happened previously with sqlite).
sql-interactive-mode
is built in and fairly easy to extend. To integrate with
it, I whipped up sql-duckdb.el based on the sqlite config.
To use it, drop the file in your lisp directory and add this to .emacs:
(require 'sql-duckdb)
To start a session: M-x sql-duckdb
. Enter a database filename to connect to or
blank to use an in-memory database.
Getting multiline previous command history to work was confusing. Instead of
just hitting Enter, you have to use C-j sql-accumulate-and-indent
.