Python, how to check if a result set is empty?

后端 未结 7 1355
予麋鹿
予麋鹿 2021-02-02 05:26

I have a sql statement that returns no hits. For example, \'select * from TAB where 1 = 2\'.

I want to check how many rows are returned,

cu         


        
7条回答
  •  南旧
    南旧 (楼主)
    2021-02-02 06:14

    For reference, cursor.rowcount will only return on CREATE, UPDATE and DELETE statements:

     |  rowcount
     |      This read-only attribute specifies the number of rows the last DML statement
     |      (INSERT, UPDATE, DELETE) affected.  This is set to -1 for SELECT statements.
    

提交回复
热议问题