class Update(DragonNetDBConnection): def __init__(self): self.sf = Smartformatter() self.sf.define(user_table='ssismdl_user', _id='id') super().__init__() def change_idnumber(self, username, idnumber): """ Change the user who lists themselves as having this email address to idnumber """ self.sf.define(username=username, idnumber=idnumber) possibles = self.sql( self.sf("select {_id} from {user_table} where username = '******'") )() if len(possibles) > 1: print("Already have a username by that email address") return elif len(possibles) == 0: print("No user by that username!") print(username) return self.sf.define(idnum=possibles[0][0]) print( self.sf("About to id #{idnum} in table {user_table}, setting its idnumber to {idnumber}") ) self.sql( self.sf("update {user_table} set idnumber = '{idnumber}' where id = {idnum}") )()
self._db[teacher] += 1 def total(self): return len(list(self._db.keys())) if __name__ == '__main__': class Config: verbose = False courses = True teachers = True students = True students = Students(Config()) teachers = Teachers() ns = Smartformatter() for student_key in students.get_student_keys(): student = students.get_student(student_key) for teacher in student.get_teachers_as_list(): teachers.add(teacher) ns.total_load = 0 teacher_tuples = [] for ns.teacher in teachers._db.keys(): ns.total_load += teachers._db[ns.teacher] teacher_tuples.append( (ns.teacher, teachers._db[ns.teacher]) ) ns.total_teachers = teachers.total()
def __init__(self): self.sf = Smartformatter() self.sf.define(user_table='ssismdl_user', _id='id') super().__init__()