Phyton pymssql连接数据库

import pymssql

# conn = pymssql.connect(server='longdabing',user='sa',password='sasa',database='longtest') 两种写法都是正确的
conn = pymssql.connect('longdabing','sa','sasa','longtest')
cursor = conn.cursor()
cursor.execute("SELECT * FROM dbo.infor")
row = cursor.fetchone()
while row:
    print("ID=%d, No=%s, Name=%s, Object=%s, Score=%s" % (row[0], row[1], row[2], row[3], row[4]))
    row = cursor.fetchone()
conn.close()

 

想玩游戏,就来开始学习下火热的Pyhton。

 

posted @ 2018-07-15 18:00  longdb  阅读(210)  评论(0编辑  收藏  举报