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
Post a Comment