diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2020-09-24 16:57:10 +0530 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2020-09-24 16:57:10 +0530 |
commit | 0ff2f3189ea5aea74303138b531994026222d524 (patch) | |
tree | f68b69293c3a03cbf364874c93e76f0166003455 /api.py | |
parent | a3e3511e3b6a7419ce5aed5847e481595971b7bc (diff) |
added exception handling for unknown hostname
Diffstat (limited to 'api.py')
-rw-r--r-- | api.py | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -19,13 +19,16 @@ def gen_word(N, min_N_dig, min_N_low): dbFailing = False import mysql.connector as con -from mysql.connector.errors import InterfaceError +from mysql.connector.errors import InterfaceError, DatabaseError try: mycon = con.connect(host=flask_app.config['DB_HOST'],user=flask_app.config['DB_USER'],password=flask_app.config['DB_PASSWORD'],port=flask_app.config['DB_PORT'],database=flask_app.config['DB_NAME']) mycursor = mycon.cursor() except InterfaceError: print("Could not connect to the database!") dbFailing = True +except DatabaseError: + print("Unknown Host") + dbFailing = True """ @flask_app.route("/") |