Use additional conditions so sqlite will work or postgresql
Also added trim to prevent a trailing space from breaking the dsn string for sqlite. Also added debug lines helpful for testing.
This commit is contained in:
@@ -9,6 +9,7 @@ assert(freeswitch, "Require FreeSWITCH environment")
|
|||||||
-----------------------------------------------------------
|
-----------------------------------------------------------
|
||||||
local FsDatabase = {} do
|
local FsDatabase = {} do
|
||||||
|
|
||||||
|
require "resources.functions.trim"
|
||||||
require "resources.functions.file_exists"
|
require "resources.functions.file_exists"
|
||||||
require "resources.functions.database_handle"
|
require "resources.functions.database_handle"
|
||||||
|
|
||||||
@@ -17,8 +18,19 @@ FsDatabase._backend_name = 'native'
|
|||||||
|
|
||||||
function FsDatabase.new(name)
|
function FsDatabase.new(name)
|
||||||
local dbh = assert(name)
|
local dbh = assert(name)
|
||||||
if type(name) == 'string' then
|
if (type(name) == 'string') then
|
||||||
dbh = database_handle(name)
|
--debug information
|
||||||
|
--freeswitch.consoleLog("notice","name " .. name .. "\n");
|
||||||
|
--freeswitch.consoleLog("notice","database.type " .. database.type .. "\n");
|
||||||
|
--freeswitch.consoleLog("notice","database.name " .. database.name .. "\n");
|
||||||
|
--freeswitch.consoleLog("notice","database.path " .. database.path .. "\n");
|
||||||
|
|
||||||
|
--handle switch sqlite
|
||||||
|
if (name == 'switch' and database.type == 'sqlite' and database.path ~= nil and database.name ~= nil) then
|
||||||
|
dbh = freeswitch.Dbh("sqlite://"..trim(database.path).."/"..trim(database.name))
|
||||||
|
else
|
||||||
|
dbh = database_handle(name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
assert(dbh:connected())
|
assert(dbh:connected())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user