为Python安装pymssql模块来连接SQLServer

时间:2020-12-17 10:33:59

1、安装依赖包

yum install -y gcc python-devel

2、安装freetds

下载地址:http://pan.baidu.com/s/1pLKtFBl

tar zxvf freetds-0.82.tar.gz

cd freetds-0.82

./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld --enable-shared --enable-static

make && make install

echo "/usr/local/freetds/lib" >> /etc/ld.so.conf.d/freetds.conf

ldconfig -v

3、安装setuptools

下载地址:http://pan.baidu.com/s/1bpDW8cZ

tar zxvf setuptools-28.8.0.tar.gz

cd setuptools-28.7.1

python setup.py install

4、安装pymssql

下载地址:http://pan.baidu.com/s/1kVa0DKz

tar zxvf pymssql-2.1.0.tar.gz

cd pymssql-2.1.0

python setup.py install

注意:不安装freetds,会报如下错误

error: command 'gcc' failed with exit status 1