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 -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -