-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbinterface.py
132 lines (112 loc) · 4.32 KB
/
dbinterface.py
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Database User Interface
#
# Note that these functions contain input and output
# such as print() and input(), but do NOT contain any
# actual database code. The database is handled by
# a separate class.
from musicdb import MusicDB
# Create a database object that will handle all the DB stuff.
dbobj = MusicDB()
def searchArtist():
name = input("Enter the name of the artist: ")
result = dbobj.searchAlbum(name)
for row in result:
print(row)
def searchLastName():
name = input("Enter the last name of the employee: ")
result = dbobj.searchEmployee(name)
for row in result:
print(row)
def listCustomers():
cur = dbobj.listCustomers()
# Fetch some the results
result = cur.fetchall()
for row in result:
firstName, lastName, customerID = row
print("%s %s" % (firstName, lastName))
print("ID: %d" % customerID)
print()
def readEmployee():
cur = dbobj.listEmployee()
result = cur.fetchall()
for row in result:
FirstName, LastName, EmployeeId = row
print("%s %s" % (FirstName, LastName))
print("ID: %d" % EmployeeId)
print()
def readAlbums():
cur = dbobj.listAlbum()
result = cur.fetchall()
for row in result:
AlbumId, Title, ArtistId = row
print("%d" % (AlbumId))
print("Title: %s" % (Title))
print("ID: %d" % ArtistId)
print()
def readgenres():
cur = dbobj.listgenres()
result = cur.fetchall()
for row in result:
GenreId, Name = row
print("Id: %d" % (GenreId))
print("Name: %s" % Name)
print()
def updateEmployeeEmail():
#get the last name of the Employee
lName = input("Enter a last name: ")
empID = input("Enter the Employee ID: ")
newEmail = input("Enter the new email: ")
dbobj.updateEmployeeEmail(lName, empID, newEmail)
print()
def updateCustomerEmail():
#get the last name of the Employee
lName = input("Enter a last name: ")
cusID = input("Enter the Customers ID: ")
newEmail = input("Enter the new email: ")
dbobj.updateCustomerEmail(lName, cusID, newEmail)
print()
def createCustomer():
#get all the infomation you need
print("please fill in all the infomation to make a new customer profile")
FirstName = input("Enter your first name: ")
LastName = input("Enter your last name: ")
CustomerId = input("Enter your ID (must be above 1000):")
Address = input("Enter your address: ")
City = input("Enter your city: ")
State = input("Enter your state: ")
Country = input("Enter your country: ")
PostalCode = input("Enter your postal code: ")
Phone = input("Enter your phone number: ")
Email = input("Enter your email address: ")
dbobj.createCustomer(FirstName, LastName, CustomerId, Address, City,
State, Country, PostalCode, Phone, Email)
print()
def createEmployee():
#get all the infomation you need
print("please fill in all the infomation to make a new Employee profile")
FirstName = input("Enter your first name: ")
LastName = input("Enter your last name: ")
EmployeeId = input("Enter your employee ID (cannont be below 9): ")
Title = input("Your new title: ")
ReportsTo = input("Enter the ID of your boss: ")
Birthday = input("Enter your birthday? (yyyy-mm-dd): ")
HireDate= input("Enter the day you were hired (yyyy-mm-dd): ")
Address = input("Enter your address: ")
City = input("Enter your city: ")
State = input("Enter your state: ")
Country = input("Enter your country: ")
PostalCode = input("Enter your postal code: ")
Phone = input("Enter your phone number: ")
Fax = input("Enter your Fax number: ")
Email = input("Enter your email address: ")
dbobj.createEmployee(EmployeeId, LastName, FirstName, Title, ReportsTo, Birthday, HireDate,
Address, City, State, Country, PostalCode, Phone, Fax, Email)
print()
def deleteTrack():
trackID = input("Enter trackID of the track you want to delete: ")
dbobj.deleteTrack(trackID)
print()
def deleteInvoice():
invoiceID = input("Enter invoiceID of the invoice you want to delete: ")
dbobj.deleteInvoice(invoiceID)
print()