System information
Driver = /usr/lib/libodbcpsql.so
Setup = /usr/lib/libodbcpsqlS.so
FileUsage = 1
On Ubuntu, the /etc/odbcinst.ini file will be blank, so you’ll need to add the data to that
configuration file. Add the following to the odbcinst.ini file:
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver = /usr/lib/odbc/psqlodbca.so
Setup = /usr/lib/odbc/libodbcpsqlS.so
FileUsage = 1
On 64-bit systems, you will need to change the path of the libraries
from /usr/lib/ to /usr/lib64/ in order to access the correct library files.
In either case, you can use cat > /etc/odbcinst.ini to write a clean configuration file, as
we’ve done in other chapters. Just use Ctrl
+D to save the file once you’re done.
Verify that the system is able to see the driver by running the following command. It
should return the label name PostgreSQL if all is well:
$ odbcinst -q -d
[PostgreSQL]
Next, configure the /etc/odbc.ini file, which is used to create an identifier that Asterisk
will use to reference this configuration. If at any point in the future you need to change
the database to something else, you simply need to reconfigure this file, allowing
Asterisk to continue to point to the same place
‡
:
[asterisk-connector]
Description = PostgreSQL connection to 'asterisk' database
Driver = PostgreSQL
Database = asterisk
Servername = localhost
UserName = asterisk
Password = welcome
Port = 5432
Protocol = 8.1
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
ConnSettings =
‡ Yes, this is excessively verbose. The only entries you really need are Driver, Database, and Servername. Even
the UserName and Password are specified elsewhere, as you’ll see later (although these are required when testing,
as in “Validating the ODBC Connector” on page 351).
348 | Chapter 16: Relational Database Integration