71GA 71GA - 28 days ago 8
LaTeX Question

LuaLaTeX with LuaSQL on Archlinux

I am working on a LuaLaTeX file which would take data from my database using LuaSQL. So this are the

003-v1.tex
and
003-v1.lua
files that I came up with:

003-v1.tex
file:

\documentclass{article}
\usepackage{luacode}

% Lua kodo vpišemo v ločeno datoteko zaradi syntax highlithing
\directlua{dofile('003-v1.lua')}

\newcommand{\stranke}{\luadirect{stranke()}}

\begin{document}
\begin{tabular}{ll}
\hline
id stranke & ime \\
\hline
\stranke
\hline
\end{tabular}
\end{document}


003-v1.lua
file:

function stranke ()

package.cpath = package.cpath .. ";/usr/lib/i386-linux-gnu/lua/5.1/?.so"
luasql = require "luasql.mysql"

env = assert (luasql.mysql())
con = assert (env:connect("linux_krozki","root","mypassword"))
cur = assert (con:execute("SELECT * FROM stranke"))

vnos = cur:fetch ({}, "a")

while vnos do

print(
string.format([[%s & %s \\]], vnos.id_stranke, vnos.ime)
)
vnos = cur:fetch (vnos, "a")

end

end


This files ought to work but when I try to compile using
lualatex 003-v1.tex
I get error:

This is LuaTeX, Version 1.0.4 (TeX Live 2017/Arch Linux)
restricted system commands enabled.
(./003-v1.tex
LaTeX2e <2017-04-15>
(using write cache: /home/ziga/.texlive/texmf-var/luatex-cache/generic)(using r
ead cache: /var/lib/texmf/luatex-cache/generic /home/ziga/.texlive/texmf-var/lu
atex-cache/generic)
luaotfload | main : initialization completed in 0.144 seconds
Babel <3.12> and hyphenation patterns for 1 language(s) loaded.
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size10.clo(load luc: /home/ziga/.texlive/
texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc)))
(/usr/share/texmf-dist/tex/lualatex/luacode/luacode.sty
(/usr/share/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texmf-dist/tex/luatex/luatexbase/luatexbase.sty
(/usr/share/texmf-dist/tex/luatex/ctablestack/ctablestack.sty))) (./003-v1.aux)
003-v1.lua:8: module 'luasql.mysql' not found:
no field package.preload['luasql.mysql']
[kpse lua searcher] file not found: 'luasql.mysql'
[kpse C searcher] file not found: 'luasql.mysql'
no file '/usr/local/lib/lua/5.2/luasql.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './luasql.so'
no file '/usr/lib/i386-linux-gnu/lua/5.1/luasql.so'
stack traceback:
[C]: in function 'require'
003-v1.lua:8: in function 'stranke'
[\directlua]:1: in main chunk.
\luadirect ... { \luacode@maybe@printdbg {#1} #1 }

l.14 \stranke


And according to this topic this error arrizes because LuaLaTeX can't load module
luasql.mysql
while
lua
can on its own. How do I know this? If I comment out first line (
function stranke ()
) and last line (
end
) from
003-v1.lua
before compiling with
lua 003-v1.lua
I get an output which is completely fine:

1 & Žiga \\
2 & Ranja \\
3 & Romana \\


So my question is, how to make sure that module
luasql.mysql
loads when LuaLateX is called? I am on Archlinux and am using texlive. I heard that people compile the texlive again with support for luasql, but can't find the step by step guide... That would be awesome! It would be even better if there is anyone who already compiled it.




Here is the info about my Texlive version:

[ziga@laptop ~]$ pacman -Qs tex | grep live
local/texlive-bibtexextra 2017.44915-1 (texlive-most)
local/texlive-bin 2017.44590-2
local/texlive-core 2017.44918-1 (texlive-most)
local/texlive-fontsextra 2017.44818-1 (texlive-most)
local/texlive-formatsextra 2017.44177-2 (texlive-most)
local/texlive-games 2017.44131-1 (texlive-most)
local/texlive-humanities 2017.44833-1 (texlive-most)
local/texlive-langchinese 2017.44333-1 (texlive-lang)
local/texlive-langcyrillic 2017.44895-1 (texlive-lang)
local/texlive-langextra 2017.44908-1 (texlive-lang)
local/texlive-langgreek 2017.44917-1 (texlive-lang)
local/texlive-langjapanese 2017.44914-1 (texlive-lang)
local/texlive-langkorean 2017.44467-1 (texlive-lang)
local/texlive-latexextra 2017.44907-1 (texlive-most)
local/texlive-music 2017.44885-1 (texlive-most)
local/texlive-pictures 2017.44899-1 (texlive-most)
local/texlive-pstricks 2017.44742-1 (texlive-most)
local/texlive-publishers 2017.44916-1 (texlive-most)
local/texlive-science 2017.44906-1 (texlive-most)

Answer Source

We found an answer on Archlinux forums after this thread was posted. It looks like there are some internal problems with Lua language - package.cpath wasn't able to reckognize the questionmark, so ?.so had to be changed into mysql.so. Can anyone explain why this happened?