Hi Iwada,
in switch.conf.xml I have:
<param name="core-db-dsn" value="pgsql://dbname=freeswitch user=freeswitch options='-c client_min_messages=NOTICE' application_name='freeswitch'" />
I also use freeswitch's Dbh to connect to different databases in postgres. This is a code snippet from a reverse lookup script which looks up callerids in a postgresql table. Note that I connect to a different database than the core here ("freeswitch" in the core vs. "reverselookup" in this lua script):
-- connect to db using freeswitch core
local dbh = freeswitch.Dbh("pgsql://dbname=reverselookup user=freeswitch options='-c client_min_messages=NOTICE' application_name='freeswitch'")
assert(dbh:connected())
local name
dbh:query("SELECT displayname, company FROM names WHERE number='" .. cidnum_e164 .. "'", function(row)
--name = row.displayname .. " (" .. row.company .. ")"
name = row.displayname
return 1
end)
if name == nil then
freeswitch.consoleLog("info", "reverselookup.lua: No match found for " .. cidnum .. " (" .. cidnum_e164 .. ")\n")
name = cidnum
end
I don't use passwords here because freeswitch and postgresql run on the same machine and can use psql's ident authentication. you have to have a user/role in postgresql for the uid that is running freeswitch.
best regards,
markus