I am still a novice in this field, writing only basic papers with Tex. Altough my question may still lay beyond my practice I would like to ask if any Tex is able to load data (texts and pictures specificly) from SQL database, like Helios Inuvio for example? My desire is to create reports via Tex from the database. Do not need specific answer, at least what to do to go further.

  • There are some related questions here on the site, mostly a bit older bit probably still relevant, for example tex.stackexchange.com/questions/3697/… and tex.stackexchange.com/questions/48193/…. Links taken from the Related section with question links on the right side of this question page, underneath the advertisement, you may find other interesting information there as well. – Marijn Feb 3 at 7:42
  • 1
    Even if it were somehow possible, it would be much cleaner to export the data from SQL with a separate script, and then generate the Tex from it. – Polygnome Feb 3 at 15:04
  • To understand.. The main idea was to keep specific data updated according to the changing data in database, every time new PDF is generated. – John Feb 4 at 10:21

there are basically two approaches you can take:

  • Use shell-escape: If you pass -shell-escape to TeX, then you can run arbitrary shell commands and read their output. Since many databases come with command line cliens which are more or less scriptable, this allows you to access the database.

  • Or use LuaTeX. LuaTeX allows you to use arbitrary Lua code, so you can integrate it with any Lua SQL library. See e.g. Using LuaLaTeX and SQLite3 for SQLite or the LuaSQL library for a more general system. These require you to install these libraries separately, they do not come as part of your typical TeX distribution.


I don't know if you can do it directly with TeX (probably can with some arcane code), however if you are interested in dynamic reports it is worth looking at either

Both R and Python can work really well with SQL databases, and process data, making them much more flexible than vanilla TeX.

I have personal experience with sweave and knitr, and they both work remarkably well and consistently, once you take some time to understand their underlying philosophy and differences from TeX. I haven't really managed to start with Pweave, but its in my scopes .

  • FYI, knitr does not force you to use markdown, it can also deal with LaTeX in Rnw documents. See Chapter 3.2.1 if the knitr book. – CL. Feb 3 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.