opensips

How to configure modules to use postgresql


I'm struggling to find any information on how to set up OpenSIPS with postgresql for modules like B2B, dialog, etc.

Example for the b2b_entities module I configure it as follows:

loadmodule "db_postgres.so"
modparam("b2b_entities", "db_url", "postgresql://postgres@spark_pgsql:5432")

When I try to run openSIPS I'm getting the following error in the log:

"level": "ERROR", "module": "core", "function": "db_check_api", "message": "module db_postgresql does not export db_use_table function\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_bind_api> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "db_bind_mod", "message": "using export interface to bind db_postgresql\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_use_table> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_init> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_close> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_query> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_fetch_result> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_raw_query> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_free_result> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_insert> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_delete> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_update> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_replace> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_last_inserted_id> in module db_postgresql not found\n"
"level": "DBG", "module": "core", "function": "find_mod_export", "message": "<db_insert_update> in module db_postgresql not found\n"

Any help would be appreciated.


Solution

  • The scheme part of OpenSIPS database URLs is directly connected to the db_ module names (the full list of modules may be found here). The scheme of db_mysql is mysql://, db_sqlite is sqlite://, etc.

    In your case, try changing the URL to postgres://..., since the client module is named db_postgres.

    Additionally, make sure to explicitly give a database name in the URL string, otherwise Postgres will assume the same DB name as the URL username (postgres by default), which could lead to access denied: postgres://postgres@127.0.0.1/opensips.