LUA - How to use variables within database.query()

Discussion created by admin.nimsoft on Oct 28, 2008
Latest reply on Oct 28, 2008 by admin.nimsoft
Hello guys,

i'm just developing some lua scripts and i'm having problems inserting variables to a database using database.query().

I am cycling through a for-loop and get some alarm data like al.hostname and al.severity. Now i want to save these values within a seperate database (for other specific analytics and usage...). My code looks something like this:

for i=1,#al do
      database.query("INSERT INTO alarms Values ('al.hostname','al.severity')")

In general, this statement works and writes data into the db, but i can't manage it that LUA interprets the variables so that the actual values are inserted into the db. I already tried it with %s (like using printf) or with ".al.hostname." (like within php), but can't get it to work. The example scripts just use static text, but no variables...

Any suggestions?

Thanks in advance,
Hubert Haas