SQL is not enough, is it?
and C isn't and java isn't
Production facilities are hardly ever programmed in a single language. There's always wrappers using shell-scripting, SQL for data retrieval and one optimised C-program for this nifty complex operational issue which can only be solved with a particular C-library.
Hence, any application in production uses many languages.
One file, two products
Literate programming (especially when using org-mode/babel) can handle the combination of documentation and code while using different languages. One can produce code and source-code documentation (two seperate end-products) from one source.
Let's assume there is data in a RDBMS, which we want to count and report by e-mail to some address. The SQL to deliver the data is:
select count(*) as numsamples from events where pit::date = CURRENT_DATE
numsamples |
---|
313 |
We can unit-test this SQL, as org-mode allows us to hit C-c C-c
in
this block of code in order to perform the query and return the
result into our text.
Most SQL-interpreters cannot send e-mails, so we need some code to e-mail the result:
mail -E -s "Number of samples today" "evsig@thedomain.com"
Our production application consists of these two units together and will look like:
psql -d evlog -qt -c " select count(*) as numsamples from events where pit::date = CURRENT_DATE " | \ mail -E -s "Number of samples today" "evsig@thedomain.com"
As the script this document generates is called informevsig
in the
file-system, one can include an install-script to be run:
scp informevsig prodsys:/usr/local/bin/
about this title
The document to generate the scripts has the same source as the document you are reading now.
Most scripts are bare bone, the amount of fancy stuff is kept to an absolute minimum in order to present only the concepts at hand and only that.
This title was written between 14th and 17th of July 2017