我已经下载并安装了Apache 2.4.4(它现在带有mod_lua模块)。启用,像这样:无法从mod_lua连接到postgresql
--httpd.conf--
LoadModule lua_module modules/mod_lua.so
AddHandler lua-script .lua
跑一个简单的脚本和它的作品。
--htdocs/hello.lua--
function handle(r)
r.content_type = "text/html"
r:puts("Hello Lua World!\n")
end
我现在想连接到本地PG数据库,但无法得到它的工作。
function handle(r)
r.content_type = "text/html"
r:puts("Hello Lua World!\n")
local db, err = r:dbacquire("postgres", "postgres://user:[email protected]/db0")
if not err then
r:puts("connected!")
else
r:puts("couldn't connect!")
end
end
没有任何错误信息。我错过了进一步的配置吗?
感谢您的任何意见!
尝试使用LuaSQL连接脱身。 – hjpotter92 2013-03-04 21:15:04
知道,但我希望能使用mod_lua /阿帕奇内的新的数据库访问的API。 http://httpd.apache.org/docs/2.4/mod/mod_lua.html#databases – rebnoob 2013-03-04 21:48:35
是的,但要检查,如果连接处于活动状态。另外,在'puts()'调用之后包含'db:close()'。 – hjpotter92 2013-03-04 21:52:33