if you use lua, use Freeswitch.dbh, you may want to have a look at http://wiki.freeswitch.org/wiki/Lua_freeswitch_dbh