PDA

View Full Version : use of luacom not possible from within webserver pages ?



rgouyet
March 18th, 2012, 04:26 PM
Hi,

I try to connect to a database from witihin an .lhtlm page.

I use this lua function wich works in a lua script in Girder GUI but not from the lhtml page :
local cn = luacom.CreateObject("ADODB.Connection")

when I include the database.lua file in my script it failed on line 12 :
assert(dblua_data.connection)

The function that set this variable is
dblua_data.connection = luacom.CreateObject("ADODB.Connection")

Why does it not works from a webserver script ?

Thanks for help

Ron
March 18th, 2012, 04:35 PM
I would not do com inside a webpage. There are threading issues related to com. Probably better to do the database access using LuaSQL which has a ODBC driver.

rgouyet
March 18th, 2012, 05:18 PM
Thank you Ron.
I succesfully connect to my database thru ODBC with LuaSQL.

Does luasql.mysql() is supported ? It seems not.

attempt to call field `mysql' (a nil value) stack traceback: [string "WebServer"]:31: in main chunk

But luasql.odbc() is working ...

Ron
March 18th, 2012, 05:24 PM
yeah I don't think we have a mysql driver currently for LuaSQL. At least you can get to your data through ODBC!

shaun5
March 18th, 2012, 08:09 PM
SQLite works well too....