1. Installation
freetd installation method 1
1. Install freetds
#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
Doing what the documentation says, always getting an error
error: command 'gcc' failed with exit status 1
freetd installation method 2
Check whether the python-devel package is installed. If not, please install it.
#yum install -y python-devel
#tar zxvf freetds-0.82.tar.gz
#cd freetds-0.82
#./configure No parameters are added here
#make
#make install
#ldconfig -v
Other installations
In addition, you need to check whether the following packages exist
libxml2 libxml2-dev libxslt* zlib gcc openssl
2. Install setuptools
#tar zxvf setuptools-3.5.1.tar.gz
#cd setuptools-3.5.1
#python setup.py install
3. Install pymssql
#tar zxvf pymssql-2.1.0.tar.gz
#cd pymssql-2.1.0
#python setup.py install
2. Error reporting and resolution
2.1 20017 error
Solution: Connection parameter configuration charset='utf-8'
tds_version = '7.1'
2.2 The connection is successful but the query returns empty
Reason: Use manual submission after cursor.execute(sql): connector.commit(), manual submission does not take effect, big pit
Solution: Configure automatic submission connector.autocommit(True) after connection
2.3 Connection error DB-Lib error message 20002
1. It may be that the charset setting is incorrect: utf8 or CP936
2. It may be caused by incorrect filling of the server IP, database name, etc.
Reference documentation:
python pymssql installation_linux installation pymssql process_weixin_39638929's blog-CSDN blog