Intellipool server monitoring blog

Welcome Guest ( Log In | Register )

Rating 0
entry Sep 10 2007, 03:07 PM
INM Lua IDE have been updated with support for SQL queries. Currently supported by the TLuaDB API is the ODBC client type. In future releases this will be expanded to cover native support for MySQL, SQL Server, Oracle, Postgress, IBM DB and Interbase.

INM 3.3 will have this API included, this IDE release is intended for developers that will get a head start developing new Lua scripts.

The update IDE can be downloaded here:
Download page
Documentation

Please post any feedback in this blog post.

Here follows an example how to use the new API, TLuaDB.

CODE
----------------------------------------------------------------------------------------------------------
-- INM Lua API example (C) 2007 Intellipool AB
-- Demonstrates the Lua database interface
----------------------------------------------------------------------------------------------------------

-- Create new DB object
DB = TLuaDB();

-- Connect to a DSN
if (DB:Connect("DSN=testdsn;",TLuaDB.CLIENT_ODBC) == true) then

       -- Insert a few rows
       bok = DB:Execute("insert into test (iID,sTest) values(10,'test');");

       -- Select all rows in table
       bok = DB:Execute("select * from test;");

       if ( bok == true) then
               -- Check if we got rows back

               if(DB:ResultAvilable() == true) then

                       -- Print how many columns this table contains
                       iColCount = DB:ColCount();
                       print("Columns in this table: "..iColCount);

                       -- Get first row
                       while (DB:NextRow() == true) do
                               for iCurrentCol = 1, iColCount do
                                       -- GetColType and GetCol take a 1 based index
                                       iColType = DB:GetColType(iCurrentCol);
                                       sData = DB:GetCol(iCurrentCol);

                                       -- Print column #, column type and data
                                       print("Col #"..iCurrentCol.." Type: "..iColType.." Data: "..sData);
                               end
                       end
               end
       else
               -- Print error and exit
               SetExitStatus("Failed" .. DB:GetErrorDescription(),false);
       end
else
       -- Print error and exit
       SetExitStatus("Failed to connect"..DB:GetErrorDescription(),false);
end

 
« Next Oldest · Intellipool server monitoring blog · Next Newest »
 
About Intellipool
Intellipool is a privately held software developer based in Sundsvall, Sweden. This blog is here to post news and tips regarding our product Intellipool Network Monitor.

Intellipool Network Monitor is a system for agentless server monitoring, alerting and reporting of a large selection of operating systems and SNMP capable devices.





SMTWTFS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30