Adjust the LUA database connection to accommodate native PostgreSQL support and the recent change to the database connection syntax.

This commit is contained in:
Mark Crane
2013-03-31 08:18:41 +00:00
parent 3483c7134b
commit ac203b91ed
17 changed files with 169 additions and 215 deletions

View File

@@ -27,13 +27,23 @@ digit_timeout = "5000";
extension = argv[1];
--database
--connect to the database
--local dbh = freeswitch.Dbh("dsn","user","pass"); -- when using ODBC
local dbh = freeswitch.Dbh("core:core"); -- when using sqlite
--include config.lua
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
dofile(scripts_dir.."/resources/config.lua");
--exits the script if we didn't connect properly
assert(dbh:connected());
--add the file_exists function
dofile(scripts_dir.."/resources/functions/file_exists.lua");
--connect to the database
if (file_exists(database_dir.."/core.db") then
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db");
else
dbh = freeswitch.Dbh(database["switch"]);
end
--exits the script if we didn't connect properly
assert(dbh:connected());
if ( session:ready() ) then
session:answer( );