Call Us Today! 877.742.2583




Page tree
Skip to end of metadata
Go to start of metadata

About

The FreeSWITCH core provides the API for modules to make connections to databases.

 Click here to expand Table of Contents

DSN

Data Source Names. Database connections are defined with DSN in XML configuration parameters like "core-db-dsn" and "odbc-dsn".

Format

The generic DSN format is <type>://<connection string>

Types

FreeSWITCH currently supports the following DSN types:

 

SQLite

DSN for SQLite
sqlite://filename
sqlite:///usr/local/freeswitch/db/mega.db

Note the 3rd / (slash) in the second example to indicate a local absolute path.

PostgreSQL

DSN for PostgreSQL
pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password= options='-c client_min_messages=NOTICE' application_name='freeswitch'"
ODBC

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"/>

or
<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:"/>

or
<param name="core-db-dsn" value="odbc://database:username"/>

DSN only

Note the two colons at the end.

DSN for ODBC without username
 <param name="core-db-dsn" value="database::"/>

or
<param name="core-db-dsn" value="odbc://database"/> 

No DSN

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">

See Also

1 Comment

  1. 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.