PDA

View Full Version : ODBC Plugin: MySQL add-in.



ShadowUK
12-14-2008, 03:57 AM
This is a little plugin that is meant to clip-in to the ODBC action plugin.

It provides the following functions.

Handle = MySQL.OpenConnection(Server, Username, Password, Port);
Boolean = MySQL.IsValidHandle(Handle);
MySQL.Query(Handle, Query);
Table = MySQL.QueryToTable(Handle, Query);
MySQL.SelectDatabase(Handle, Database);

It's meant for ease of use with MySQL databases.

Example:


-- Open the connection to the database.
hnd = MySQL.OpenConnection("localhost", "root", "06713502", 3306);

-- Select the database we're going to use.
MySQL.SelectDatabase(hnd, "test");

-- Query the database.
result = MySQL.QueryToTable(hnd, "SELECT * FROM `Hello`");

-- Create a string containing the dumped table.
str = "Dumping table `Hello`..\r\n\tColumns: "..result.Columns.."\r\n\tColumn Names: "..Table.Concat(result.ColumnNames, ", ", 1, result.Columns).."\r\n";

-- Enumerate through the table.
for K, V in pairs(result.Data) do
-- Append to the string.
str = str.."\r\nRow #"..tostring(K);

-- Go through the row now.
for X, Y in pairs(V) do
str = str.."\r\n\t"..tostring(X).." = "..tostring(Y);
end
end

-- Show the user.
Dialog.Message("MySQL Action Plugin", str);


I've attached the XML and the luac file.

You can use this add-in by putting the MySQL.luac file in AutoPlay/Scripts then putting the following code in On Preload/Globals/On Startup/...


require "MySQL.luac";

actionstk..
12-14-2008, 05:07 AM
:eek: Wowww.. Big thk for nice Plugin... :yes

RizlaUK
12-17-2008, 05:44 PM
why luac ?

MSP
12-22-2008, 12:05 PM
I get an error because the luac file is looking for:

C:\Documents and Settings\Stephen Ball\Desktop\Action Plugins\MySQL.lua

What is this supposed to be?
Thank you,
MSP

ShadowUK
12-22-2008, 12:53 PM
Requesting a mod to delete this thread because I need to rethink it.

actionstk..
12-23-2008, 10:02 AM
oh sorry for my ninny.. :p