Page 4 of 4

Re: A simpler DB container.

Posted: Sat Jul 14, 2012 10:36 pm
by Rakon
With a recent update to debian wheezy, this lua script no longer works.

I have many sql/lua libs installed including liblu5.1-sql-sqlite3, lua-sql-sqlite3, liblua5.1-sql-sqlite3-2 and liblua5.1-sql-sqlite3-dev.

When mudlet is loaded I get the echo "Lua module sqlite3 loaded" however in my main script where I include this dba.lua script, I get an error on script compliation:

Code: Select all

Trying to activated script main failed reason: ...dba.lua:14: attempt to index global luasql (a nil value)

Doing a manual require outputs the following:

Code: Select all


table 0x41dc3ad8 {
  'sqlite3': function
  '_DESCRIPTION': 'LuaSQL is a simple interface from Lua to a DBMS'
  '_COPYRIGHT': 'Copyright (C) 2003-2012 Kepler Project'
  '_VERSION': 'LuaSQL 2.3.0'
}


however the dba.lua file still does not stop having the 'lua.sqlite3 is nil' error.

Any ideas on how to fix this please??

Re: A simpler DB container.

Posted: Sat Jul 14, 2012 10:45 pm
by Vadi
Does Mudlet say:

Code: Select all

[  OK  ]  -  Lua module sqlite3 loaded
When loading?

Re: A simpler DB container.

Posted: Sat Jul 14, 2012 10:47 pm
by Rakon
Yes, it does have that while loading.

Code: Select all

Error attempting to load file: Logging.lua
(mapper): Mudlet Mapper script for IREs (12.6.3) loaded! (homepage)
[  OK  ]  -  Lua module rex_pcre loaded
[  OK  ]  -  Lua module zip loaded
[  OK  ]  -  Lua module lfs loaded
[  OK  ]  -  Lua module sqlite3 loaded
[  OK  ]  -  mudlet-lua API & Geyser Layout manager loaded.
[ INFO ]  -  looking up the IP address of server:www.achaea.com:2003 ...
[ INFO ]  -  The IP address of www.achaea.com has been found. It is: 69.65.42.
198
[ INFO ]  -  trying to connect to 69.65.42.198:2003 ...
[ INFO ]  -  A connection has been established successfully.

Re: A simpler DB container.

Posted: Sat Jul 14, 2012 11:12 pm
by Rakon
For the time being, until a better solution is found, I've hacked the dba.lua for a together:

Code: Select all

- - 6: require "luasql.sqlite3"

++ 6: luasql = require "luasql.sqlite3"
This allows the dba.lua to work without any other modifications, though obviously not an ideal situation

Re: A simpler DB container.

Posted: Sat Jul 14, 2012 11:47 pm
by Vadi
Hm, actually - it just might be. It's better practice for Lua modules these days not to assign themselves to the global namespace, but to return themselves instead.