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。