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