Skip to content

Commit

Permalink
added basic logic to attribute insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Couillard authored and Nicholas Couillard committed Oct 5, 2023
1 parent e6fda06 commit d40a08d
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions DynamoDB.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
from boto3 import resource
from boto3.dynamodb.conditions import Attr, Key
import math

course_table = resource('dynamodb').Table('Courses')

def insert():
def insert(courseId, courseSection, courseLevel, courseDepartment, courseProfessor, courseEnrolledStudents, courseMaxStudents, courseStartTime, courseEndTime, courseIsOpen):
courseInsertion = course_table.put_item(
Item = {
'CourseId' : 'CSE1010', # partition key
'Section' : '001L', # sort key?
'Level' : '1000', # useful attribute for searching
'Department' : 'CSE', # useful attribute for searching
'Professor' : 'Gregory Jackson', # TODO: support multiple instructors
'StudentsEnrolled' : 0, # useful attribute for professor
'StartTime' : 1630, # is storing times in the form of 24-hour time easier? it's simple to convert when necessary
'EndTime' : 1720,
'OpenStatus' : True # this attribute could be useful for hiding unavailable courses
'CourseId' : courseId, # partition key
'Section' : courseSection, # sort key?
'Level' : courseLevel, # useful attribute for searching
'Department' : courseDepartment, # useful attribute for searching
'Professor' : courseProfessor, # TODO: support multiple instructors
'StudentsEnrolled' : courseEnrolledStudents, # useful attribute for professor
'MaxStudents' : courseMaxStudents, # can calculate OpenStatus using some logic
'StartTime' : courseStartTime, # is storing times in the form of 24-hour time easier? it's simple to convert when necessary
'EndTime' : courseEndTime,
'OpenStatus' : courseIsOpen # this attribute could be useful for hiding unavailable courses
}
)

print(f"Insert response: {courseInsertion}")

if __name__ == '__main__':
insert()

# NONE OF THE INFO COLLECTING WILL LIKELY BE DONE IN PYTHON, THIS IS PROBABLY VUE STUFF. JUST FOR DEMO
courseDepartment = input("Enter department: ").upper()
courseNumber = int(input("\nEnter course number: ")) # TODO: Error handling for invalid inputs
courseSection = input("\nEnter course section: ")
if len(courseSection) == 1:
courseSection = '00' + courseSection
elif len(courseSection) == 2:
courseSection = '0' + courseSection
courseType = input("\nSelect the type of course if needed: Laboratory, Discussion: ")
if courseType == "Laboratory":
courseSection += 'L'
elif courseType == "Discussion":
courseSection += 'D'
courseLevel = math.floor(courseNumber / 1000) * 1000
courseId = courseDepartment + str(courseNumber)
courseProfessor = input("\nEnter professor: ") # TODO: support multiple instructors
courseMaxStudents = int(input("\nEnrollment slots: "))
courseStartTime = input("\nStart time: ") # TODO: Turn 12-hour time into 24-hour time integer
courseEndTime = input("\nEnd time: ") # TODO: Turn 12-hour time into 24-hour time integer
courseEnrolledStudents = 0
courseIsOpen = bool(courseMaxStudents - courseEnrolledStudents)

insert(courseId, courseSection, courseLevel, courseDepartment, courseProfessor, courseEnrolledStudents, courseMaxStudents, courseStartTime, courseEndTime, courseIsOpen)

0 comments on commit d40a08d

Please sign in to comment.