summaryrefslogtreecommitdiff
path: root/tex/context/base/m-sql.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/m-sql.mkiv')
-rw-r--r--tex/context/base/m-sql.mkiv57
1 files changed, 57 insertions, 0 deletions
diff --git a/tex/context/base/m-sql.mkiv b/tex/context/base/m-sql.mkiv
new file mode 100644
index 000000000..bccfa9cb8
--- /dev/null
+++ b/tex/context/base/m-sql.mkiv
@@ -0,0 +1,57 @@
+%D \module
+%D [ file=m-sql,
+%D version=2012.07.12,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=SQL,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{util-tpl}{}
+\registerctxluafile{util-sql}{}
+
+\startluacode
+
+local sql = utilities.sql
+
+function sql.show(specification)
+ local data = specification.data
+ if data and #data > 0 then
+ local keys = specification.order or table.sortedkeys(data[1])
+ local align = specification.align
+ local template = "|"
+ if type(align) == "table" then
+ for i=1,#keys do
+ template = template .. (align[keys[i]] or "c") .. "|"
+ end
+ else
+ template = template .. string.rep((align or "c").. "|",#keys)
+ end
+ context.starttabulate { template }
+ context.NC()
+ for i=1,#keys do
+ context(keys[i])
+ context.NC()
+ end
+ context.NR()
+ context.HL()
+ for i=specification.first or 1,specification.last or #data do
+ local d = data[i]
+ context.NC()
+ for i=1,#keys do
+ context(d[keys[i]])
+ context.NC()
+ end
+ context.NR()
+ end
+ context.stoptabulate()
+ end
+end
+
+\stopluacode
+
+\endinput