Commit f63707d6 authored by Antoine Kryus's avatar Antoine Kryus
Browse files

add correction python nb seance par spectacle

parent 5ca6f302
......@@ -17,4 +17,4 @@ def display(conn):
cur.execute(sql)
conn.commit()
SELECT * FROM MembreExterieur WHERE nom = 1;
#SELECT * FROM MembreExterieur WHERE nom = 1;
......@@ -20,9 +20,9 @@ DATABASE = "dbnf18p074"
conn = psycopg2.connect("dbname='dbnf18p074' user='nf18p074' host='tuxa.sme.utc' password='0KnpbtUH'")
cur = conn.cursor()
print("\n\n-------- MENU ---------")
option=1
while option != 0:
print("\n\n-------- MENU ---------")
print("[1] Ajouter une donnée")
print("[2] Afficher une table")
print("[3] Supprimer une donnée")
......@@ -45,7 +45,7 @@ while option != 0:
elif option == 4:
update.update(conn)
elif option == 5:
nbSeanceParSpectacle.nbSeanceParSpectacle(conn)
nbSeanceParSpectacle.execute(conn)
elif option == 6:
horaireseance.horaireSeance(conn)
elif option == 7:
......
......@@ -4,15 +4,27 @@ import psycopg2
from tabulate import tabulate
def display(conn):
def execute(conn):
cur = conn.cursor()
column_names = []
data_rows = []
spectacle = input("Entrez l'id du spectacle dont vous voulez connaitre le nombre de séance. \n")
# afficher la table Spectacle pour se repérer
print("\n")
sql = "SELECT * FROM Spectacle;"
cur.execute(sql)
nb_field = len(cur.description)
column_names = [desc[0] for desc in cur.description]
for row in cur:
data_rows.append(row)
print (tabulate(data_rows, headers=column_names))
spectacle = input("Entrez l'id du spectacle dont vous voulez connaitre le nombre de séance(s) : \n-> ")
sql = "SELECT COUNT(*) AS idseance FROM Seance WHERE spectacle = " + spectacle + ";"
print(sql)
#print(sql)
cur.execute(sql)
conn.commit()
print("\nIl y a %s séance(s) pour ce spectacle.\n\n" % str(cur.fetchone()[0]))
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