README.org
June 14, 2022 ยท View on GitHub
- ob-dsq.el
Babel functions for the [[https://github.com/multiprocessio/dsq][dsq CLI tool]] by [[https://multiprocess.io][Multiprocess Labs.]] :heart:
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:
#+begin_src emacs-lisp (use-package ob-dsq :ensure) #+end_src
- 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 [[https://orgmode.org/manual/Using-Header-Arguments.html][header arguments]] described in the list below.
See the [[examples][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 [[examples/README.org#getting-started][a filename]], the [[examples/README.org#querying-org-references-in-local-or-other-files][name of an Org reference]] that builds tabular or list data (an Org table, an Org source block, etc.), or [[examples/README.org#querying-results-of-elisp-forms][an Elisp form]] that generates any of the above or the data to query directly. -
:cache-- set toyesto enabledsq's [[https://github.com/multiprocessio/dsq#caching][caching feature]]. Requiresdsqversion 0.15.0 or higher. -
:convert-numbers-- set toyes(default) to enabledsq's [[https://github.com/multiprocessio/dsq#converting-numbers-in-csv-and-tsv-files][number conversion feature]]. Requiresdsqversion 0.19.0 or higher. -
:header-- set toyes(default) to include header row in table results. -
:hlines-- set toyesto include horizontal lines between rows in table results. -
:null-value,:false-value-- customize the rendering ofnullandfalsevalues in results.