Linux ODBC: PostgreSQL

Note that the bundled SQDR PostgreSQL driver is recommended in most situations, but psqlODBC driver can be also be used.

Note that the psqlODBC driver supplied by the Red Hat/Oracle 8.x distribution may be old and inadequate for working with a recent PostgreSQL server. We recommend installing a recent driver from the PostgreSQL repository.

Downloading & Installing the latest driver

For example, to obtain the v15 driver

Add a repository as documented at https://www.postgresql.org/download/linux/redhat/ and install the desired driver:

# sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# sudo dnf install postgresql15-odbc

If you encounter problems due to an old existing repo definition (e.g. Bad GPG Signature error or attempt to locate metadata for an old version that is no longer supported, move or delete /etc/yum.repos.d/pgdg-redhat-all.repo and try again.

/etc/odbcinst.ini

Add the following to /etc/odbcinst.ini:

[PostgreSQL Unicode]
Driver=/usr/pgsql-15/lib/psqlodbcw.so
UsageCount=1

[PostgreSQL Unicode(x64)]
Driver=/usr/pgsql-15/lib/psqlodbcw.so
UsageCount=1

Sample odbc.ini entry

[MyPostgreSQL]
Description=PostgreSQL ODBC Driver Unicode
Driver=PostgreSQL Unicode
Servername=QA10
Database=postgres
Port=5432
MaxVarcharSize=32767
MaxLongVarcharSize=214748364