[INFO] Using LuaSQL with LuaCast (For Ashita)

Post Reply
User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

[INFO] Using LuaSQL with LuaCast (For Ashita)

Post by atom0s » Wed Feb 12, 2014 2:29 pm

Here is a quick setup guide to get LuaCast to work with LuaSQL.
Image
  • Next, open your main.lua and add the following to the top:

    Code: Select all

    package.cpath = AshitaCore.AshitaInstallPath .. '\\Extensions\\LuaCast\\clibs\\?.dll;' .. package.cpath;
    Image
  • Then you should be able to use LuaSQL with LuaCast.
Here is a small example of reading all character id and names from the chars table:

Code: Select all

require "luasql.mysql"
local env   = luasql.mysql(); -- Create MySQL object..
local con   = assert(env:connect('dspdb', 'root', 'root', 'localhost'));
local chr   = assert(con:execute("SELECT * FROM chars;"));

local data  = { chr:fetch() };

while (data ~= nil) do
    print( string.format( "%s: %s", data[1], data[3] ) );
    
    data = { chr:fetch() };
    if (data[1] == nil) then
        break;
    end
end
Attachments
clibs.7z
(677.54 KiB) Downloaded 300 times

Post Reply