Page 294 - Asterisk™: The Future of Telephony
P. 294
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 As-
terisk 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 = 7.4
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
ConnSettings =
Let’s verify that we can connect to our database using the isql application. The isql
application will not perform the connect as the root user, and must be run as the same
owner as the database. Since the owner of the asterisk database under PostgreSQL is
the asterisk user, we must create a Linux account with the same name. In Chapter 14,
we will take advantage of this user to run Asterisk as non-root.
# su - asterisk
$ echo "select 1" | isql -v asterisk-connector
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> +------------+
| ?column? |
+------------+
| 1 |
+------------+
SQLRowCount returns 1
1 rows fetched
$ exit
With unixODBC installed, configured, and verified to work, we need to recompile
Asterisk so that the ODBC modules are created and installed. Change back to your
† 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 seen later.
266 | Chapter 12: Relational Database Integration