The FreeSWITCH core provides the API for modules to make connections to databases.
Click here to expand Table of Contents
- 1 DSN
- 2 See Also
Data Source Names. Database connections are defined with DSN in XML configuration parameters like "core-db-dsn" and "odbc-dsn".
The generic DSN format is <type>://<connection string>
FreeSWITCH currently supports the following DSN types:
DSN for SQLite
Note the 3rd / (slash) in the second example to indicate a local absolute path.
DSN for PostgreSQL
pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password= options='-c client_min_messages=NOTICE' application_name='freeswitch'"
Upon the addition of multiple core database options (PostgreSQL, ODBC, SQLite), the format for the DSN changed so that FreeSWITCH knows which database type to use.
The following DSN (data source name) formats are valid for ODBC databases:
DSN with username and password
DSN for ODBC including password
<param name="core-db-dsn" value="database:username:password"/>
<param name="core-db-dsn" value="odbc://database:username:password"/>
DSN with username
Note the colon at the end.
DSN for ODBC with username only
<param name="core-db-dsn" value="database:username:"/>
<param name="core-db-dsn" value="odbc://database:username"/>
Note the two colons at the end.
DSN for ODBC without username
<param name="core-db-dsn" value="database::"/>
<param name="core-db-dsn" value="odbc://database"/>
DSN-less connections are also possible. Such connections don't require configuration in odbc.ini.
Essentially the syntax is the same options you would have in odbc.ini name-value pairs, separated by ; (semicolon)
MyODBC example (OPTION=67108864 enables batched statements):
<param name="core-db-dsn" value="odbc://DRIVER=mysql;SERVER=a.b.c.d;UID=username;PWD=secretpassword;DATABASE=freeswitch;OPTION=67108864">
|We need to specify on this page that to use mod_mariadb with MariaDB / MySQL, the database schema cannot be UTF8, otherwise an error will occur when creating table indexes with the message:'Specified key was too long'The solution is to use another character set (eg: latin1_general_ci) to avoid this. Posted by fernandojdk at Aug 13, 2019 18:26|