Skip to content

Commit 0396b4f

Browse files
committed
updated credentials for DB login
also added some testing stubs and basic list elements as functions like students
1 parent e5afe45 commit 0396b4f

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

4 DB in Python/GradeTrackerExperiments/GradeTrackerDB.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import getpass
33

44
#root password is something you set when you install mysql on your system
5-
#the default may be blank; I use python123 for testing
6-
dbconn = my.connect (host='127.0.0.1',port=3306,user='root', password='python123', db='students')
5+
#the default may be blank; I use python123 for testing (old server was root/python123)
6+
dbconn = my.connect (host='127.0.0.1',port=33067,user='root', password='', db='students')
77

88
#print(dbconn)
99
cursor = dbconn.cursor()
@@ -36,10 +36,10 @@
3636
dbconn.close()
3737

3838
#print(users)
39-
print("STUDENTS")
40-
print(students)
41-
print("FACULTY")
42-
print(faculty)
39+
#print("STUDENTS")
40+
#print(students)
41+
print("FACULTY user account for testing:")
42+
print(faculty[1][1],faculty[1][2])
4343
#print(users[1][1],users[1][2])
4444

4545
#print(grades)
@@ -62,16 +62,14 @@
6262

6363
#now define functions
6464
def enterGrades():
65-
nameToEnter = input('Student name: ')
66-
gradeToEnter = input('Grade: ')
67-
68-
if nameToEnter in students[1]:
69-
print('Adding grade for'+nameToEnter)
70-
students[nameToEnter].append(float(gradeToEnter)) #float will have a .0
71-
print(str(nameToEnter)+' now has these grades:')
72-
print(students[nameToEnter])
73-
else:
74-
print('Student not found. Please check your spelling or go back and add if new.')
65+
listStudents()
66+
thisStudentID = input('Enter the student ID: ')
67+
gradeToEnter = input('Grade to enter (eg. 98.3): ')
68+
studentIndex = int(thisStudentID)-1
69+
print('Adding grade for '+students[studentIndex][1])
70+
#students[studentIndex].append(float(gradeToEnter)) #float will have a .0
71+
print(students[studentIndex][1]+' now has these grades:')
72+
7573

7674
def removeStudent():
7775
nameToRemove = input('Who do you want to remove? ')
@@ -82,6 +80,13 @@ def removeStudent():
8280
else:
8381
print('Student not found.')
8482

83+
def listStudents():
84+
for student in students:
85+
thisStudent = ""
86+
for item in student:
87+
thisStudent += str(item) + " "
88+
print(thisStudent)
89+
8590
def averageStudents():
8691
for student in students:
8792
grades = students[student]
@@ -133,6 +138,4 @@ def main():
133138
else:
134139
print('Invalid password.')
135140
else:
136-
print('User not found.')
137-
else:
138-
print('Invalid user. Check your spelling.')
141+
print('User not found.')

0 commit comments

Comments
 (0)