Python& pymssql:执行命令后从数据库返回消息?

时间:2015-03-23 20:44:29

标签: python pymssql

使用pymsql

执行SQL查询后,是否有办法访问返回消息?
cursor.execute("SELECT * FROM table;")
cursor.get_return_message?

1 个答案:

答案 0 :(得分:0)

我相信至少有四种可以这种方式使用:

 rows = cursor.execute("SELECT * FROM table")

 print("Total # of rows: " + str(rows.rowcount))

 for row in rows:
     print("Looping over row #" + str(rows.rownumber))

     if(rows.rowcount == rows.rownumber):
         print("Yay, we're done.')

还有Cursor.connection。更多信息:

http://pymssql.org/en/latest/ref/pymssql.html

向下滚动到Cursor对象属性(文档中拼写错误的Cusor)。祝你好运!