To install the Pymssql module:
Centos:
Yum Install Python-devel Python-setuptools
Go to https://pypi.python.org/pypi/pymssql/2.1.0 Download source package wget https://pypi.python.org/packages/source/p/pymssql/ Pymssql-2.1.0.tar.gz#md5=e955442a8cd43456cdf5c28b75147afb
Yum Install Freetds-devel
Python setup.py Build
Python setup.py Install
Be sure to install Freetds-devel, otherwise the compilation will report GCC's fault.
After compiling correctly, you should be able to import pymssql in Python.
Window version:
Https://pypi.python.org/pypi/pymssql/2.1.1#downloads
#!/usr/bin/python
Import Pymssql,sys
conn = Pymssql.connect (server= ' 192.168.1.252 ', port= ' 1433 ', user= ' sa ', password= ' xxxxxx ', database= ' xxxx ', charset= ' UTF-8 ')
print ' Connect ok ... '
cursor = Conn.cursor ()
sql = ' SELECT COUNT (*) from Sys.dm_exec_connections '
Cursor.execute (SQL)
row = Cursor.fetchone ()
Print (Row[0])
Conn.close ()
Installing pymssql and simple attempts under Linux