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


i have sql statement returns no hits. example, 'select * tab 1 = 2'.

i want check how many rows returned,

cursor.execute(query_sql)  rs = cursor.fetchall() 

here exception: "(0, 'no result set')"

how can prevend exception, check whether result set empty?

cursor.rowcount set 0.

if, however, running statement never return result set (such insert or select ... into), not need call .fetchall(); there won't result set ever such statements. calling .execute() enough run statement.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -