how to count value returned from select query in python
<p>I want to count the total number of rows returned by query. I am able to retrieved rows returned by query but what if i need to work in case when no data exits. that is when query returns no va from database.</p>

<p>the code i used to solve this problem is :</p>

<p>try:
        cur.execute(query)</p>

<pre><code>    id = cur.fetchone()[0]
    if(id is None):
        return '-1'
    else: 
        return id
</code></pre>

<p>But this doenst help when no values is returned selected from query.(when condition doesnt meet criteria defined in select statement)</p>
