[luatex] MySQL driver not found from inside LuaLaTeX
sergei.naumov at gmail.com
sergei.naumov at gmail.com
Wed Feb 28 08:57:40 CET 2024
Hi!
I am new to LuaTeX and LuaLaTeX, please, bear with my ignorance of some
probably basic things. :-) I need to get strings from MySQL database and
the test Lua code that does it works fine when it is called from the
command line:
require("string")
function projects_from_db ()
DBI = require("DBI")
dbh = assert(DBI.Connect('MySQL','serge', 'serge', 'serge',
'localhost', 3306))
sth = assert(dbh:prepare('SELECT name,budget FROM projects'))
sth:execute()
for row in sth:rows() do
print(string.format("%-55s & %7.1f \\\\",row[1],row[2]))
end
dbh:close()
end
-- projects_from_db()
However, when I put it into latex file
\usepackage{luacode}
\usepackage{luapackageloader}
\directlua{dofile('dbd.lua')}
\newcommand{\projectsfromdb}{\luadirect{projects_from_db()}}
It says that MySQL driver can not be found:
./DBI.lua:53: Cannot load driver MySQL. Available drivers are: (None)
stack traceback:
[C]: in function 'error'
./DBI.lua:53: in function 'DBI.Connect'
dbd.lua:6: in function 'projects_from_db'
[\directlua]:1: in main chunk.
\luadirect ... { \luacode at maybe@printdbg {#1} #1 }
l.64 \projectsfromdb
Why is that? I checked package.cpath from Lua and the necessary path is
there:
Lua 5.3.6 Copyright (C) 1994-2020 Lua.org, PUC-Rio
> package.cpath
/usr/lib64/lua/5.3/?.so;/usr/lib64/lua/5.3/loadall.so;./?.so
I tried to set a few environment variables:
LUAROCKS_CPATH=/usr/lib64/lua/5.3
LUAROCKS_PATH=/usr/share/lua/5.3
but it did not make any difference
--
Thanks,
Sergei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/luatex/attachments/20240228/8c826ee1/attachment.htm>
More information about the luatex
mailing list.