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
Post a Comment