VFindMe-Home Tech-Home Search

On using ODBC with PostgreSQL 9.4

Keep the ini file simple

by : November 27, 2015

When attempting to set up ODBC on an openSUSE Leap 42.1 installation I had a lot of problems gaining access to my database. There were various error messages presented, such as "native error", "connection dead", "no such database" and so on, most of which contained no useful information. My mistake was to follow online suggestions for the contents of the .odbc.ini file. The suggestion was to start with all the bells and whistles such as Protocol, Trace, Debug, and Description, but in fact this is not helpful when trying to diagnose a failure to connect.

The solution in my case was to ensure that the required Postgresql ODBC driver was in place through Yast, and then start with a very simple entry in odbc.ini:

[PostgreSQL]
Database                =(database_name)

That's it. Nothing more, if the current user values for name and password have normal access to the database in question. Other key and value pairs can be added later, but when the issue is getting a good connection to start, we need to eliminate what could be preventing a connection from happening. Once you have a working connection then adding back one pair at a time can be tested more effectively.

Now a test such as isql -v PostgreSQL (username) (password), where username and password may be already set in the current user environment, works correctly.