added try for sql connect
This commit is contained in:
@@ -145,8 +145,17 @@ dbconfig = {
|
|||||||
'raise_on_warnings': True
|
'raise_on_warnings': True
|
||||||
}
|
}
|
||||||
logger.debug("Starting SQL query for LDAPUsers")
|
logger.debug("Starting SQL query for LDAPUsers")
|
||||||
cnx = mysql.connector.connect(**dbconfig)
|
try:
|
||||||
logger.debug("SQL Connection: {0}".format(cnx))
|
cnx = mysql.connector.connect(**dbconfig)
|
||||||
|
logger.debug("SQL Connection: {0}".format(cnx))
|
||||||
|
except mysql.connector.Error as err:
|
||||||
|
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
|
||||||
|
logger.critical("Something is wrong with your user name or password")
|
||||||
|
elif err.errno == errorcode.ER_BAD_DB_ERROR:
|
||||||
|
logger.critical("Database does not exist")
|
||||||
|
else:
|
||||||
|
logger.critical(err)
|
||||||
|
exit(3)
|
||||||
cursor = cnx.cursor()
|
cursor = cnx.cursor()
|
||||||
query = ("SELECT * FROM LDAPUsers")
|
query = ("SELECT * FROM LDAPUsers")
|
||||||
logger.debug("Query: {0}".format(query))
|
logger.debug("Query: {0}".format(query))
|
||||||
|
|||||||
Reference in New Issue
Block a user