-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexampleApp.py
More file actions
88 lines (76 loc) · 3.25 KB
/
exampleApp.py
File metadata and controls
88 lines (76 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import databaseAppFunc
# We will need the other .py file to use the functions defined there / here we will only run the functions
# The try excepts in this code are REALLY basic, try editing it if you wish.
leave = False
while leave != True:
print("\nWelcome to our example app.")
print("""Options:
1. Create database (for first runs)
2. Add one record to database
3. Add many (3) records to database
4. Show records in database
5. Search a record in database with email
6. Delete one record from database
0. Exit
-----------------------------------------------------
""")
option = int(input("Enter option: "))
if option == 1:
# Create DB
try:
databaseAppFunc.create_database()
except: # This except is in case the database is all ready created / try adding try excepts in the rest of code
print("Database all ready created or other error.")
elif option == 2:
# Add a record to database
try:
first = input("Enter the first name of the user: ")
last = input("Enter the last name of the user: ")
email = input("Enter the email of the user: ")
databaseAppFunc.add_one(first, last, email)
except:
print("Database has not been created or any other Unknown Error.")
elif option == 3:
# Add many records
try:
first1 = input("Enter the first name of the user: ")
last1 = input("Enter the last name of the user: ")
email1 = input("Enter the email of the user: ")
first2 = input("Enter the first name of the user: ")
last2 = input("Enter the last name of the user: ")
email2 = input("Enter the email of the user: ")
first3 = input("Enter the first name of the user: ")
last3 = input("Enter the last name of the user: ")
email3 = input("Enter the email of the user: ")
stuff = [
(first1, last1, email1),
(first2, last2, email2),
(first3, last3, email3)
]
databaseAppFunc.add_many(stuff)
except:
print("Database has not been created or any other Unknown Error.")
elif option == 4:
# Show all records from db
try:
databaseAppFunc.show_all()
except:
print("Database has not been created or any other Unknown Error.")
elif option == 5:
# Lookup email in our database
try:
email_look = str(input("Enter email you wish to look up: "))
databaseAppFunc.email_lookup(email_look)
except:
print("No user registered with that email, database has not been created or any other Unknown Error.")
elif option == 6:
# Delete record / we need to pass rowid as String to avoid error
try:
id_delete = str(input("Enter the id of the record you wish to delete: "))
databaseAppFunc.delete_one(id_delete)
except:
print("Database has not been created or any other Unknown Error.")
else:
print("It is sad to see you go so soon. :(")
print("I hope you enjoyed this program, and hope to see you soon. Bye! :)")
leave = True