Data source name

From FreeSWITCH Wiki
Jump to: navigation, search

The FreeSWITCH core provides the API for modules to make connections to databases. These database connections are defined with data source names (DSN) in XML configuration params like "core-db-dsn", "odbc-dsn", etc.

FreeSWITCH currently supports the following DSN types:

Contents

DSN Format

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

SQLite DSNs

sqlite://filename
sqlite:///usr/local/freeswitch/db/mega.db

Note the 3rd / to indicate a local absolute path.

PostgreSQL DSNs

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

ODBC DSNs

Now (2012-11) that FreeSWITCH supports multiple core database options (PostgreSQL, ODBC, SQLite), the format for the DSN has 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

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

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

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

or

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

The following formats NO LONGER WORK (since v1.2.4)

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

 


DSN-less

DSN-less connections are also possible. Such connections don't require setting up in odbc.ini.

Essentially the syntax is the same options you would have in odbc.ini name-value pairs, separated by ;

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