Commit 16ad0bcc authored by Francois Mares's avatar Francois Mares
Browse files

Replace Client.py

parent 4839c3bd
......@@ -15,22 +15,10 @@ class Client(SQL):
''' % numero
return self._requete_sql(sql)
# TO DO
def rechercher_trajet(self, ville_depart, ville_arrivee):
sql='''
SELECT numero
FROM (train INNER JOIN horaires
ON train.numero = horaires.id_train)
INNER JOIN arret
ON arret.gare = gare.id_gare
WHERE (gare.nom_ville='%s' OR gare.nom_ville='%s');
''' % (ville_depart,ville_arrivee)
return self._requete_sql(sql)
def rechercher_correspondance(self, ville_depart, ville_arrivee):
sql_1='''
SELECT ligne, id_arret
FROM arret
SELECT ligne, id_arret
FROM arret
INNER JOIN gare
ON arret.gare = gare.id_gare
WHERE gare.nom_ville = '%s';
......@@ -39,14 +27,14 @@ class Client(SQL):
for row_1 in rows_1:
sql_2 ='''
SELECT gare
FROM arret
WHERE ligne = %d
FROM arret
WHERE ligne = %d
AND id_arret > %d
''' % (row_1[0],row_1[1])
rows_2 = self._requete_sql(sql_2)
for row_2 in rows_2:
sql_3 ='''
SELECT nom_ville
SELECT nom_ville
FROM gare
WHERE id_gare = %d;
''' % row_2[0]
......@@ -54,7 +42,7 @@ class Client(SQL):
for row_3 in rows_3:
sql_4 ='''
SELECT ligne, id_arret
FROM arret
FROM arret
INNER JOIN gare
ON arret.gare = gare.id_gare
WHERE gare.nom_ville = '%s'
......@@ -64,10 +52,10 @@ class Client(SQL):
for row_4 in rows_4:
sql_5 ='''
SELECT gare.nom_ville
FROM arret
FROM arret
INNER JOIN gare
ON gare.id_gare = arret.gare
WHERE arret.ligne = %d
WHERE arret.ligne = %d
AND arret.id_arret > %d
AND gare.nom_ville <> '%s';
''' % (row_4[0],row_4[1],ville_depart)
......@@ -76,9 +64,34 @@ class Client(SQL):
if (row_5[0] == ville_arrivee):
print("Depuis %s empruntez la ligne %d jusque %s, puis empruntez la ligne %d jusque %s" %(ville_depart,row_1[0],row_3[0],row_4[0],ville_arrivee))
return
p = Client()
p.rechercher_correspondance('Paris','Toulouse')
# SCRIPTS FONCTIONS
def _script_rechercher_correspondance(self):
print("ville_depart << ")
ville_depart=input()
print("ville_arrivee << ")
ville_arrivee=input()
self.rechercher_correspondance(ville_depart, ville_arrivee)
# MAIN
def __main__(self):
menu=True
while menu:
menu=False
print("=============== MENU CLIENT ===============")
print("1 >> rechercher correspondance")
print("2 >> rien")
print("\n Autre entrée >> quitter le menu")
choice=input()
if choice == '1':
self._script_rechercher_correspondance()
menu=True
if choice == '2':
menu=True
......
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