A simpler DB container.

Share your scripts and packages with other Mudlet users.
User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: A simpler DB container.

Post 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??
Last edited by Rakon on Sat Jul 14, 2012 10:47 pm, edited 1 time in total.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: A simpler DB container.

Post by Vadi »

Does Mudlet say:

Code: Select all

[  OK  ]  -  Lua module sqlite3 loaded
When loading?

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: A simpler DB container.

Post 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.

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: A simpler DB container.

Post 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

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: A simpler DB container.

Post 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.

Post Reply