added try for sql connect
This commit is contained in:
@@ -145,8 +145,17 @@ dbconfig = {
|
||||
'raise_on_warnings': True
|
||||
}
|
||||
logger.debug("Starting SQL query for LDAPUsers")
|
||||
try:
|
||||
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()
|
||||
query = ("SELECT * FROM LDAPUsers")
|
||||
logger.debug("Query: {0}".format(query))
|
||||
|
||||
Reference in New Issue
Block a user