The MySQLdb has a args tuple from .Error , you could use it like this:
try:
myconnection = MySQLdb.connect (
<args for the connection setup >
except MySQLdb.Error , <somevariable>:
print "Error %d %s " % (somevariable.args[0] , somevariable.args[1])
sys.exit() (or what you want to do if an error occurs)
the first [0] contains an errorcode the second one [1] a string describing the error.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How can I use error messages from the MySQL database in a Python program?
Regards,
Egon Frerich
The MySQLdb has a args tuple from .Error , you could use it like this:
try:
myconnection = MySQLdb.connect (
<args for the connection setup >
except MySQLdb.Error , <somevariable>:
print "Error %d %s " % (somevariable.args[0] , somevariable.args[1])
sys.exit() (or what you want to do if an error occurs)
the first [0] contains an errorcode the second one [1] a string describing the error.