Créer un menu
Exemple :
1
#!/usr/bin/python3
2
3
import psycopg2
4
import forms
5
import reports
6
7
HOST = "localhost"
8
USER = "me"
9
PASSWORD = "secret"
10
DATABASE = "mydb"
11
12
conn = psycopg2.connect("host=%s dbname=%s user=%s password=%s" % (HOST, DATABASE, USER, PASSWORD))
13
14
choice = '1'
15
while choice == '1' or choice == '2':
16
print ("Pour ajouter un philosophe à la base, entrez 1")
17
print ("Pour voir la liste des philosophes, entrez 2")
18
print ("Pour sortir, entrez autre chose")
19
choice = input()
20
if choice == '1':
21
forms.addPhilo(conn)
22
if choice == '2':
23
reports.printPhilo(conn)
24
print(choice)
25
26
conn.close()