Client.py 907 Bytes
Newer Older
Francois Mares's avatar
Francois Mares committed
1
2
3
4
5

from SQL import SQL

class Client(SQL):

Francois Mares's avatar
Francois Mares committed
6
7
8
    def __init__(self,HOST=None, DATABASE=None, PASSWORD=None, USER=None):
        super().__init__(HOST, DATABASE, PASSWORD, USER)

Francois Mares's avatar
Francois Mares committed
9
    # TO DO
Francois Mares's avatar
Francois Mares committed
10
11
12
    def consulter_horaire_train(self,numero):
        sql='''
            SELECT depart, arrivee
Francois Mares's avatar
Francois Mares committed
13
            FROM horaires INNER JOIN train
Francois Mares's avatar
Francois Mares committed
14
15
16
            ON train.numero = horaires.id_train
            WHERE train.numero=%d;
            ''' % numero
Francois Mares's avatar
Francois Mares committed
17
        return self._requete_sql(sql)
Francois Mares's avatar
Francois Mares committed
18
19
20
21
22
23
24
25
26
27
28

    # 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)
Francois Mares's avatar
Francois Mares committed
29
        return self._requete_sql(sql)
Francois Mares's avatar
Francois Mares committed
30
31
32
33
34