views:

436

answers:

2

Hi All,

Just starting to get to grips with python and MySQLdb and was wondering

  1. Where is the best play to put a try/catch block for the connection to MySQL. At the MySQLdb.connect point? Also should there be one when ever i query?

  2. What exceptions should i be catching on any of these blocks?

thanks for any help

Cheers Mark

A: 

I think that the connections and the query can raised errors so you should have try/excepy for both of them.

luc
+4  A: 

Catch the MySQLdb.Error, while connecting and while executing query

Anurag Uniyal