python - Stop MySQLdb from crashing -


i'm using mysqldb connect database run queries. however, if password incorrect or mysqldb fails connect database, script stops running. instead, receive error message string, , continue script (as completion of queries not essential other parts of script). possible?

the script stops running because .connect() call raises exception.

you can catch exception try:, except: handler:

import mysqldb  try:     connection = mysqldb.connect(...) except mysqldb.error ex:     print "the connection failed: {}".format(ex) 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -