通过ODBC连接PostgreSQL

一、ODBC安装

1)UnixODBC安装

* yum安装
    # yum install -y unixODBC.x86_64

* 验证安装
    # rpm -qa | grep unixODBC
    unixODBC-2.3.1-11.el7.x86_64

2)PostgresqlODBC安装

* yum安装
    # yum install -y postgresql-odbc.x86_64

* 验证安装
    # rpm -qa | grep postgresql-odbc
    postgresql-odbc-09.03.0100-2.el7.x86_64

二、ODBC配置

1)查看odbcinst

# cat /etc/odbcinst.ini
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver      = /usr/lib/psqlodbcw.so
Setup       = /usr/lib/libodbcpsqlS.so
Driver64    = /usr/lib64/psqlodbcw.so
Setup64     = /usr/lib64/libodbcpsqlS.so
FileUsage   = 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2)配置odbc

# vim /etc/odbc.ini
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[pg]
Description = Test to pg
Driver = PostgreSQL
Database = postgres
Servername = 192.168.9.139
UserName = admin
Password = admin
Port = 5432
ReadOnly = 0
ConnSettings = set client_encoding to UTF8
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

3)验证odbc

* isql访问
    # isql pg admin admin
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页