Commit 838dc093 authored by Martin Schneider's avatar Martin Schneider
Browse files

update app

parent 4dd0acaf
......@@ -274,26 +274,63 @@ def informations_oeuvres():
print(" empruntée d'un autre musée")
print()
raw = cur.fetchone()
"""
def insert_salle():
cur = conn.cursor()
sql = "SELECT nom FROM Expo_temp;"
cur.execute(sql)
raw = cur.fetchone()
expos = []
print("\n Veuillez selectionner une des expositions temporaires :\n>")
raws = cur.fetchall
raws = cur.fetchall()
print("\n Veuillez selectionner une des expositions temporaires :\n")
for i, raw in enumerate(raws):
print(f"{i} : {raw[0]} ", end ="")
expo = raws[input()][0]
cur = conn.cursor()
sql = "INSERT INTO Salle VALUES (3, 50); INSERT INTO Exposer VALUES (3, 'Neolithique');"
print(">")
expo = raws[int(input())][0]
non_init_rooms = list(range(1, 21))
sql = "SELECT num from Salle"
cur.execute(sql)
raws = cur.fetchall()
for i, raw in enumerate(raws):
if raw[0] in non_init_rooms:
del non_init_rooms[non_init_rooms.index(raw[0])]
available_rooms = list(range(1, 21))
sql = "SELECT salle from Exposer"
cur.execute(sql)
"""
raws = cur.fetchall()
for i, raw in enumerate(raws):
if raw[0] in available_rooms:
del available_rooms[available_rooms.index(raw[0])]
if len(available_rooms) == 0:
print("\nAucune salle disponible\n")
else :
print("\nSalles disponibles : \n")
for room in available_rooms:
print(f"{room} ", end="")
print(f"\nVeuillez choisir une salle à dédier à l'exposition {expo}\n>")
salle = input()
if salle in non_init_rooms:
sql = f"INSERT INTO Salle VALUES ({salle}, 50);"
try:
cur.execute(sql)
conn.commit()
print(f"La salle numero {salle} a bien été initialisée\n")
except psycopg2.IntegrityError as e:
print("contraintes non respectées\n")
print(f"Message système : {e}\n")
conn.rollback()
sql = f"INSERT INTO Exposer VALUES ({salle}, '{expo}');"
try:
cur.execute(sql)
conn.commit()
print(f"La salle numero {salle} a bien été initialisée\n")
except psycopg2.IntegrityError as e:
print("contraintes non respectées\n")
print(f"Message système : {e}\n")
conn.rollback()
def main():
cont = 0
cont = 1
while cont == 1:
print(conn)
menu()
......@@ -310,7 +347,7 @@ def menu():
print(" 21. Insertion oeuvre néolithique")
print(" 22. Creer une nouvelle exposition permanente")
print(" 23. ")
print(" 24. ")
print(" 24. Associer une salle à une exposition temporaire")
print(" 25. ")
print(" 26. ")
......@@ -378,6 +415,9 @@ def menu():
if choice == 22:
inserer_expoperm()
if choice == 24:
insert_salle()
if __name__ == '__main__':
main()
Supports Markdown
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