• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

Lua Odbc With Debian Error Path ODBC? (1 Viewer)

Geoandroid

Newcomer
Joined
Apr 5, 2021
Messages
1
Reaction score
0
Code->
odbc = require "odbc"
dbassert = odbc.assert

cnn = odbc.connect('MariaDB-server', 'xx', 'x')

stmt = cnn:execute('SELECT Host, user, password FROM mysql.user;')
stmt:foreach(function(f1, f2, f3)
print(string.format("host: %s, user: %s, clave: %s", f1, f2, f3));
end)
assert(stmt:closed()) -- foreach close cursor
assert(not stmt:destroyed()) -- statement valid


Error:

[email protected]:/usr/src/ajto/lua_Mysql# lua prueba_mysql.lua
lua: prueba_mysql.lua:1: module 'odbc' not found:
no field package.preload['odbc']
no file '/usr/local/share/lua/5.3/odbc.lua'
no file '/usr/local/share/lua/5.3/odbc/init.lua'
no file '/usr/local/lib/lua/5.3/odbc.lua'
no file '/usr/local/lib/lua/5.3/odbc/init.lua'
no file '/usr/share/lua/5.3/odbc.lua'
no file '/usr/share/lua/5.3/odbc/init.lua'
no file './odbc.lua'
no file './odbc/init.lua'
no file '/usr/local/lib/lua/5.3/odbc.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.3/odbc.so'
no file '/usr/lib/lua/5.3/odbc.so'
no file '/usr/local/lib/lua/5.3/loadall.so'
no file './odbc.so'
stack traceback:
[C]: in function 'require'
prueba_mysql.lua:1: in main chunk
[C]: in ?
 

dinsdale247

Moderator
Staff member
Community Patron
Creator of WinLua
Joined
Nov 17, 2020
Messages
93
Reaction score
34
Location
Victoria BC
Website
winlua.net
This is telling you that it can't find the odbc package for lua. Have you installed it? Is it supposed to be in '/usr/src/ajto/lua_Mysql'? If your odbc package is not in a standard place (e.g. installed with LuaRocks or other package manager) then you will need to specify the path to the module. There are a number of ways to do that. The easiest for testing purposes is to modify package.path and package.cpath.

*note: untested code.
Lua:
package.path = "/my/special/path/?.lua;/my/special/?/init.lua;" .. package.path
package.cpath = "/my/special/path/?.so;" .. package.cpath
 
Top