Skip to content

Emacs: Babel functions for the `dsq` CLI tool by Multiprocess Labs

License

Notifications You must be signed in to change notification settings

fritzgrabo/ob-dsq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ob-dsq.el

Babel functions for the dsq CLI tool by Multiprocess Labs. ❤️

dsq is a command-line tool for running SQL queries against JSON, CSV, Excel, Parquet, and more.

This package adds Org tables, Org quotes and Org source block results to this list.

Installation

If you use MELPA, an easy way to install this package is via package-install. Alternatively, download ob-dsq.el, put it in your load-path and require it.

If you use both MELPA and use-package, you can use this, too:

(use-package ob-dsq
  :ensure)

Screenshot

An SQL query that spans a JSON file and an Org table.

screenshots/screenshot.png

Quickstart

dsq source code blocks use the custom :input header argument (see below) to specify one or more data sources, then run the SQL query in the source code block on them. Besides regular files, ob-dsq also supports Org tables, Org quotes, Org source blocks, etc. as data sources.

The example in the above screenshot shows a dsq source block that runs a simple SQL query spanning a JSON file named people.json an and Org table named foods in an Org file name random.org.

Custom Header Arguments

ob-dsq uses the custom header arguments described in the list below.

See the examples directory for a lot more features and customization options provided by Org Babel in general and ob-dsq specifically, such as specifying the result’s type and formatting, the various options for passing variables into the query, querying results of an Org source block, and more!

  • :input – the list of data sources to query. A data source can be a filename, the name of an Org reference that builds tabular or list data (an Org table, an Org source block, etc.), or an Elisp form that generates any of the above or the data to query directly.
  • :cache – set to yes to enable dsq’s caching feature. Requires dsq version 0.15.0 or higher.
  • :convert-numbers – set to yes (default) to enable dsq’s number conversion feature. Requires dsq version 0.19.0 or higher.
  • :header – set to yes (default) to include header row in table results.
  • :hlines – set to yes to include horizontal lines between rows in table results.
  • :null-value, :false-value – customize the rendering of null and false values in results.

About

Emacs: Babel functions for the `dsq` CLI tool by Multiprocess Labs

Resources

License

Stars

Watchers

Forks