Install pymssql under Linux

Source: Internet
Author: User

Win under Install Pymssql, because I do not have the system administrative privileges, cannot install,

That had to be installed under Linux ROM.

The following article helps me to fix it.

http://blog.csdn.net/five3/article/details/16338191

Versions of: https://pypi.python.org/pypi/pymssql/

Windows can download the installer file, which is compiled directly and can be installed directly

There are several basic class libraries that need to be installed under Linux:

Cpython:pip Install Cpython # #Python包

Freetds-dev:yum Install freetds-devel.x86_64/apt-get install Freetds-dev # #linux包

Final installation Pymssql:pip Install Pymssql

ImportPymssql Conn= Pymssql.connect (Host=host, User=user, password=Password, database=database, charset='UTF8', port='1433', as_dict=False) Cursor=conn.cursor () SQL="SELECT * from payment where ID in (59,60)"cursor.execute (SQL) Results=Cursor.fetchall () forRowinchResults:PrintRow
 fromOsImportgetenvImportPymssqlserver= Getenv ("Pymssql_test_server") User= Getenv ("Pymssql_test_username") Password= Getenv ("Pymssql_test_password") Conn= Pymssql.connect (server, user, password,"tempdb") Cursor=conn.cursor () cursor.execute ("""IF object_id (' persons ', ' U ') is not a null DROP table personscreate table persons (ID INT not NULL, name Varch AR (+), SalesRep VARCHAR (+), PRIMARY KEY (ID))""") Cursor.executemany ("INSERT into Persons VALUES (%d,%s,%s)",    [(1,'John Smith','John Doe'),     (2,'Jane Doe','Joe Dog'),     (3,'Mike T.','Sarah H..')])#You must call commit () to persist your data if you don't set autocommit to TrueConn.commit () cursor.execute ('SELECT * from persons WHERE salesrep=%s','John Doe') Row=Cursor.fetchone () whilerow:Print("id=%d, name=%s"% (Row[0], row[1]) Row=Cursor.fetchone () conn.close ( )

Install pymssql 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.