centos7离线安装配置驱动pymssql,pyodbc和cx_Oracle


离线安装pymssql及驱动freetds


python调用sqlserver依赖pymssql+freetds驱动,freetds依赖gcc

离线安装gcc


  • gcc-4.8.5相关依赖包:
cpp-4.8.5-36.el7.x86_64.rpm
gcc-4.8.5-36.el7.x86_64.rpm
glibc-2.17-260.el7.x86_64.rpm
glibc-common-2.17-260.el7.x86_64.rpm
glibc-devel-2.17-260.el7.x86_64.rpm
glibc-headers-2.17-260.el7.x86_64.rpm
kernel-headers-3.10.0-957.el7.x86_64.rpm
libgcc-4.8.5-36.el7.x86_64.rpm
libgomp-4.8.5-36.el7.x86_64.rpm
libmpc-1.0.1-3.el7.x86_64.rpm
mpfr-3.1.1-4.el7.x86_64.rpm

依赖包下载地址:https://pkgs.org/

  • 安装上述依赖包
#查看glibc-2.17-260.el7.x86_64.rpm 及 glibc-common-2.17-260.el7.x86_64.rpm,是否已安装,避免安装冲突
rpm -qa | grep glibc;
---------------------------------------
> glibc-common-2.17-55.el7.x86_64
> glibc-2.17-55.el7.x86_64
---------------------------------------
#升级相关依赖包避免冲突
rpm -Uvh glibc-2.17-260.el7.x86_64.rpm glibc-common-2.17-260.el7.x86_64.rpm libgomp-4.8.5-36.el7.x86_64.rpm libgcc-4.8.5-36.el7.x86_64.rpm;
#安装剩下的依赖包
rpm -ivh gcc-4.8.5-36.el7.x86_64.rpm cpp-4.8.5-36.el7.x86_64.rpm glibc-devel-2.17-260.el7.x86_64.rpm glibc-headers-2.17-260.el7.x86_64.rpm kernel-headers-3.10.0-957.el7.x86_64.rpm libmpc-1.0.1-3.el7.x86_64.rpm mpfr-3.1.1-4.el7.x86_64.rpm;
#查看gcc版本
gcc -v
----------------------------------------
>Using built-in specs.
>COLLECT_GCC=gcc
>COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
>Target: x86_64-redhat-linux
>Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
>Thread model: posix
>gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
----------------------------------------
#安装成功

离线安装freeTDS


  • 下载freetds-1.00.109

官网下载页面:http://www.freetds.org/files/stable/
版本下载地址:http://www.freetds.org/files/stable/freetds-1.00.109.tar.gz

  • 编译安装freetds
tar xvf freetds-1.00.109.tar.gz;
cd freetds-1.00.109;
#--with-unixodbc=/usr/local/unixODBC-2.3.7
./configure --prefix=/usr/local/freetds --with-tdsver=7.4 --enable-msdblib --enable-dbmfix --enable-shared --enable-static;
make;
make install;
#解释
-------------------------------------------
>--prefix设置FreeTDS的安装目录
>--with-tdsver设置TDS版本
>--enable-msdblib允许Microsoft数据库函数库
-------------------------------------------

#将tsql命令加入环境变量
-------------------------------------------

vim ~/.bashrc;

-------------------------------------------
>FREETDS_HOME=/usr/local/freetds
>export PATH=$FREETDS_HOME/bin:$PATH
-------------------------------------------

source ~/.bashrc;

-------------------------------------------
tsql -C;   #查看版本信息
-------------------------------------------
>Compile-time settings (established with the "configure" script)
>                            Version: freetds v1.00.109
>             freetds.conf directory: /usr/local/freetds/etc
>     MS db-lib source compatibility: yes
>        Sybase binary compatibility: no
>                      Thread safety: yes
>                      iconv library: yes
>                        TDS version: 7.4
>                              iODBC: no
>                           unixodbc: no
>              SSPI "trusted" logins: no
>                           Kerberos: no
>                            OpenSSL: no
>                             GnuTLS: no
>                               MARS: no
-----------------------------------------------------------
#库文件加载
echo "/usr/local/freetds/lib" > /etc/ld.so.conf.d/freetds.conf;
ldconfig;
  • 修改配置文件,连接数据库
vim /usr/local/freetds/etc/freetds.conf;

------------------------------------
#sqlserver 2012配置
>[sql-server-2012]
>		host = xxx.xxx.xxx
>		port = 1433
>		tds version = 7.4
#sqlserver 2005配置
>[2005SQL]
>		host = xxx.xxx.xxx
>		port = 1433
>		tds version = 8.0
#sqlserver 2008配置
>[sql-server-2008]
>		host = xxx.xxx.xxx
>		port = 1433
>		tds version = 8.0
>		client chaeset = UTF-8
------------------------------------
#测试连接
tsql -S sql-server-2008 -U 用户名 -P 密码;
use test;#使用指定数据库
go;

离线安装pymssql


  • 离线安装pip

扩展包下载地址:https://pypi.org/project

tar xvf setuptools-0.6c11.tar.gz;
tar xvf pip-18.1.tar.gz;
cd setuptools-0.6c11 && python setup.py install;
cd pip-18.1 && python setup.py install;
  • pip安装pymssql
pip install pymssql-2.1.4-cp27-cp27mu-manylinux1_x86_64.whl;
python;
----------------------------------
>import pymssql
>
  • pymssql及驱动安装完毕

离线安装cx_Oracle及驱动


python调用oracle数据依赖于cx_Oracle+oracle-instantclient

离线安装oracle客户端

  • 安装oracle 11g

下载地址:https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
根据oracle的版本下载对应的rpm包:
清单:
       oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
       oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
       oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm

rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
  • 修改环境变量(三种方式)
#对所有用户生效(永久)
vim /etc/profile
source /etc/profile
#对单一用户生效(永久)   用户目录下文件/home/xxx/
vim ~/.bash_profile;
source ~/.bash_profile;
#执行允许export(对当前shell临时有效)
export ..........
#----------------------------------------------------------
vim ~/.bash_profile;
-----------------------------------------------------------
>export ORACLE_HOME=/usr/lib/oracle/11.2/client64
>export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
-----------------------------------------------------------
source ~/.bash_profile;
echo $ORACLE_HOME;#检查生效

#新建软连接
cd /usr/lib/oracle/11.2/client64/lib && ln –s libclntsh.so.11.1 libclntsh.so

安装cx_Oracle

下载地址:https://pypi.org/project/cx-Oracle/


  • 安装cx_Oracle扩展包
pip install cx_Oracle-7.0.0-cp27-cp27mu-manylinux1_x86_64.whl;
python;
>import cx_Oracle
>cx_Oracle.SessionPool(user= 't', password= 't', dsn= '192.168.0.xxx:1521/orcl', min=1, max=10, increment=1)
>> :OK!

离线安装pyodbc


安装依赖

yum install -y gcc-c++ python-devel
离线安装请自行查询


安装unixODBC

tar xvf unixODBC-2.3.7.tar.gz;
cd unixODBC-2.3.7/
./configure --prefix=/usr/local/unixODBC-2.3.7 --includedir=/usr/include --libdir=/usr/local/lib -bindir=/usr/bin --sysconfdir=/usr/local/etc;
make && make install

安装pyodbc

pip install pyodbc
或者
pip install pyodbc-4.0.28.tar.gz

登记驱动

备份

[root@dongfangyiyuan ~]# cat /usr/local/etc/odbcinst.ini 
[FreeTDS]
Description     = FreeTDS unixODBC Driver
Driver          = /usr/local/freetds/lib/libtdsodbc.so
Setup           = /usr/local/freetds/lib/libtdsodbc.so
vim /usr/local/etc/odbcinst.ini;
-------------------------------------------------
[FreeTDS]					# unixodbc驱动名称
Description=ODBC of FreeTDS for MS SQL 2008		# 简介	
Driver=/usr/local/freetds/lib/libtdsodbc.so	# 驱动所在位置
#################################################################
vim /usr/local/etc/odbc.ini;
---------------------------------------------------
[root@dongfangyiyuan ~]# cat /usr/local/etc/odbc.ini 
[BYZY]
Driver = FreeTDS
Description = odbc for sybase
Server = 192.168.3.16
Port = 5000
TDS_Version = 5.0

[BYMZ]
Driver = FreeTDS
Description = odbc for sybase
Server = 192.168.3.15
Port = 5000
TDS_Version = 5.0    

[NYZY]
Driver = FreeTDS
Description = odbc for sybase
Server = 172.31.10.202
Port = 5000
TDS_Version = 5.0    

[NYMZ]
Driver = FreeTDS
Description = odbc for sybase
Server = 172.31.10.201
Port = 5000
TDS_Version = 5.0    

[BSEMR]
Driver = FreeTDS
Description = odbc for sybase
Server = 172.31.10.87
Port = 5000
TDS_Version = 5.0    

  • 连接测试
isql -v TEST2dsn ${user} ${password};

离线安装ibm_db及db2驱动

  • 下载地址:https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/
  • 扩展包下载地址:https://pypi.org/project/ibm-db/#files
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值