Skip to content

Instantly share code, notes, and snippets.

@simonced
Last active July 1, 2017 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonced/2a4ee29ed779a563b9fb7a9d8dcc83cf to your computer and use it in GitHub Desktop.
Save simonced/2a4ee29ed779a563b9fb7a9d8dcc83cf to your computer and use it in GitHub Desktop.
org-mode 9.09 html export issue with sql blocks

See raw source for details of settings on each block and file properties

Elisp source blocks

Simple operation:

(+ 1 2)

With :exports both present to the source block, if the #+RESULTS: is missing in the org file, no results exported! (makes sense I think)


Another test, now with :exports both added to the source block AND executed with C-c-c:

(current-time-string)
Fri Jun 30 10:16:03 2017

I understand that :exports both is important to export results if present in the org file.

We can see that emacs-lip source blocks obey to #+PROPERTY: header-args :eval never-export.
Their results are exported but NOT executed during export.

Next, let’s try the SQL blocks (next section).

SQL blocks

List of tables:

show tables;
Tables_in_test
text_test

With no other parameters to the source block, the block is not executed during export BUT results are not exported.


Now with :exports both to the source block:

select now();
now()
2017-06-30 10:25:22

We can see that unlike the E-lisp source blocks, the results are parsed THEN exported.
(they did not appear/replace in the buffer as #+RESULTS: data)

The results in the org buffer is different from the one exported in HTML!

SQL blocks (working)

I learned that properties are inherited, and the properties drawer where overriding the global #+PROPERTY at the top.
But since properties can be local to “source type”, I simply fixed my properties drawer buy making it look like:

:header-args:sql: :engine mysql :dbhost localhost :dbuser root :database test :cmdline --protocol=tcp

Now, my block is not evaluated during export, the computed result in the file is simply exported.

select now();
now()
2017-06-30 10:25:22

Conclusion

TIL: Property inheritance is a real thing, important to understand when making more complex document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment