Skip to content

Latest commit

 

History

History
116 lines (96 loc) · 2.99 KB

sqlite-babel.org

File metadata and controls

116 lines (96 loc) · 2.99 KB

sqlite-babel

1 Version information

(princ (concat (format "Emacs version: %s\n" (emacs-version))
               (format "org version: %s\n" (org-version))))

2 using a table as input

Note: Do not use colons in the table fields, since they are used as field delimiters in the table import

col1col2col3
525
630
735
840
945
1050
1155
1260
1365
1470
1575

It is necessary to create the explicit table definition. The table can be read in via the .import function.

drop table if exists t1;
create table t1 (col1 INTEGER, col2 INTEGER, col3 INTEGER);
.import "$tbl" t1
select count(*) from t1;

3 SQLite table UPDATEs, column names

The :colnames yes option selects in the next block that the output table should contain a header row with the column names.

UPDATE t1 SET col3 = 2 * col2;
SELECT * FROM t1;
col1col2col3
52550
63060
73570
84080
94590
1050100
1155110
1260120
1365130
1470140
1575150

4 SELECTs and using babel blocks as functions via CALL

SELECT * FROM t1 WHERE col1>=$val;
col1col2col3
1365130
1470140
1575150

Now the filter can be called as a function using the org babel CALL syntax

col1col2col3
63060
73570
84080
94590
1050100
1155110
1260120
1365130
1470140
1575150