Installing pymssql and simple attempts under Linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.