If there is no results from the mysql query..   

how to set a variable to '0'

is the question.

```
import _mysql

def db():
    a = _mysql.connect('localhost','1','','a')
    return a

b=db()

b.query('select id from people where id=' + a + ' limit 1')
d = b.store_result()
b = d.fetch_row(0)
b = b[0][0]

```

if the mysql has no result .. then this script will error due to

```
b = b[0][0]

```

i need to set "b" to "0" if there is no such thing as b[0][0]

because when something is not found via mysql.. then i get this error

```
IndexError: tuple index out of range

```

**UPDATE**

looking for a "try" alternative. i do not understand the word "try" if i want to simply use the logic of "if does not exist" rather than "touch it and try it to see what happens first"

**UPDATE 2**

would be awesome if someone can show me the

```
a = locals().get('a', '0')

```

version of this.

**UPDATE 3**

perhaps i should run count(\*) so mysql can give me "0"
that i am looking for. and then decide if i should go back into mysql with another query or not.