Error exceptions handled in dbilayer.py
This commit is contained in:
parent
4a11f41ffd
commit
2d621a7d30
Binary file not shown.
|
@ -234,7 +234,7 @@ def dbacl_processupdateonecond(reqData):
|
|||
dbaclId = data['dbaclId']
|
||||
status = data['status']
|
||||
updateStatement = "dbaclname = '{}',dbuserid = '{}',dbaclid = '{}',status = '{}'".format(dbaclName,dbuserId,dbaclId,status)
|
||||
condition = "dbaclId = '{}'".format(dbaclId)
|
||||
condition = "dbaclid = '{}'".format(dbaclId)
|
||||
sta = dbilayer.updateValuesIndb('dbACL', updateStatement, condition)
|
||||
print(sta)
|
||||
if(sta == "Success"):
|
||||
|
|
Binary file not shown.
|
@ -15,9 +15,6 @@ import cx_Oracle
|
|||
|
||||
db_connection = cx_Oracle.connect("ganesh/ganeshm0477@//localhost:1521/xe")
|
||||
|
||||
|
||||
|
||||
|
||||
# db_connection = mysql.connector.connect(
|
||||
# host="localhost",
|
||||
# user="root",
|
||||
|
@ -82,6 +79,7 @@ def getUserActivity(tablename, fields, userData):
|
|||
output=my_database.fetchone()
|
||||
except:
|
||||
output={"Error":"No data recieved or error occured"}
|
||||
print("Error: " + str(e))
|
||||
# db_connection.close()
|
||||
print(output)
|
||||
return output
|
||||
|
@ -97,8 +95,9 @@ def readallWithoutCondition(tablename, fields):
|
|||
results = [dict(zip(columns, row)) for row in rows]
|
||||
retval = "Success"
|
||||
return results
|
||||
except :
|
||||
retval = "Failure"
|
||||
except Exception as e:
|
||||
retval = "Failed"
|
||||
print("Error: " + str(e))
|
||||
return retval
|
||||
|
||||
def readallWithCondition(tablename, fields, condition):
|
||||
|
@ -112,8 +111,9 @@ def readallWithCondition(tablename, fields, condition):
|
|||
results = [dict(zip(columns, row)) for row in rows]
|
||||
retval = "Success"
|
||||
return results
|
||||
except :
|
||||
retval = "Failure"
|
||||
except Exception as e:
|
||||
retval = "Failed"
|
||||
print("Error: " + str(e))
|
||||
return retval
|
||||
|
||||
def readOneWithcondition(tablename, fields, cond):
|
||||
|
@ -127,35 +127,38 @@ def readOneWithcondition(tablename, fields, cond):
|
|||
results = [dict(zip(columns, row)) for row in rows]
|
||||
print(rows)
|
||||
return results
|
||||
except :
|
||||
retval = "Failure"
|
||||
except Exception as e:
|
||||
retval = "Failed"
|
||||
print("Error: " + str(e))
|
||||
return retval
|
||||
|
||||
def insertIntoDBWithoutCondition(tablename,fields,data):
|
||||
my_database=db_connection.cursor()
|
||||
sql_query="INSERT INTO {} ({}) VALUES({})".format(tablename, fields, data)
|
||||
print(sql_query)
|
||||
# try:
|
||||
my_database.execute(sql_query)
|
||||
db_connection.commit()
|
||||
retval = "Success"
|
||||
return retval
|
||||
# except:
|
||||
# retval = "Failure"
|
||||
# return retval
|
||||
try:
|
||||
my_database.execute(sql_query)
|
||||
db_connection.commit()
|
||||
retval = "Success"
|
||||
return retval
|
||||
except Exception as e:
|
||||
retval = "Failed"
|
||||
print("Error: " + str(e))
|
||||
return retval
|
||||
|
||||
def updateValuesIndb(tablename,updatestatement,condition):
|
||||
my_database = db_connection.cursor()
|
||||
sql_statement = "UPDATE " + tablename + " SET " + updatestatement + " WHERE " + condition + ""
|
||||
print(sql_statement)
|
||||
# try:
|
||||
my_database.execute(sql_statement)
|
||||
db_connection.commit()
|
||||
retval = "Success"
|
||||
return retval
|
||||
# except:
|
||||
# retval = "Failure"
|
||||
# return retval
|
||||
try:
|
||||
my_database.execute(sql_statement)
|
||||
db_connection.commit()
|
||||
retval = "Success"
|
||||
return retval
|
||||
except Exception as e:
|
||||
retval = "Failed"
|
||||
print("Error: " + str(e))
|
||||
return retval
|
||||
|
||||
def updateDataWithCondition(tablename,updateStatement,condition):
|
||||
pass
|
||||
|
@ -254,6 +257,7 @@ def updateDataWithCondition(tablename,updateStatement,condition):
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'''
|
||||
|
|
Loading…
Reference in New Issue
Block a user