Commit a48da181 authored by Xiang Li's avatar Xiang Li
Browse files

Update prog.py

parent fa168750
......@@ -252,31 +252,33 @@ def updatePrescription(traitement_id, medicament_id, quantite)
def updateAnimal(name)
def ExecuteList(sqls) :
for sql in sqls:
print('SQL: ' + sql)
try:
cur.execute(sql)
except pg.Error as E:
print(E.pgerror)
conn.rollback()
return False
conn.commit()
return True
def deleteClass(nom):
sql = "DELETE FROM Classes WHERE nom='{}';".format(nom)
try:
cur.execute(sql)
except pg.Error:
print("Execute Error")
if(Execute(sql)):
print("Delete Classe Succes")
else:
print("Delete Classe Fail")
conn.rollback()
return
conn.commit()
print("Delete Classe Succes")
def deleteEspece(nom):
sql = "DELETE FROM Especes WHERE nom='{}';".format(nom)
try:
cur.execute(sql)
except pg.Error:
print("Execute Error")
if(Execute(sql)):
print("Delete Espece Succes")
else:
print("Delete Espece Fail")
conn.rollback()
return
conn.commit()
print("Delete Espece Succes")
def deleteClient(idClient):
sql = "DELETE FROM Clients WHERE id={};".format(idClient)
if(Execute(sql)):
......@@ -293,18 +295,17 @@ def deletePersonnel(idPersonnel, isVeterinaires):
print("Delete {} Succes".format(table))
else:
print("Delete Veterinaire Fail")
def deleteAnimal(idAnimal):
sql = "DELETE FROM Animaux WHERE id={};".format(idAnimal)
if(Execute(sql)):
sqls = []
sqls.append("DELETE FROM Proprietaires WHERE animal={}".format(idAnimal))
sqls.append("DELETE FROM Traitements WHERE animal={}".format(idAnimal))
sqls.append("DELETE FROM Animaux WHERE id={};".format(idAnimal))
if(ExecuteList(sqls)):
print("Delete Animal Succes")
else:
print("Delete Animal Fail")
def deleteProprietaire(idClient, idAnimal):
sql = "DELETE FROM Proprietaires WHERE client={} AND animal={};".format(idClient, idAnimal)
if(Execute(sql)):
......@@ -340,6 +341,8 @@ def deletePrescription(idTraitement, nomMolecule):
else:
print("Delete Prescription Fail")
"""
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment