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