def listAll(cls):
     query = (f"SELECT * FROM {cls.tableName}")
     results = DBConnect.getall(query, ())
     objs = []
     for result in results:
         objs.append(cls._rowToObj((result)))
     return objs
 def listPatients(cls):
     query = (f"SELECT * FROM {cls.tableName} WHERE utype=%s")
     results = DBConnect.getall(query, ("patient", ))
     users = []
     for result in results:
         users.append(cls._rowToObj(result))
     return users
 def listByDepartment(cls, deptID):
     query = (f"SELECT * FROM {cls.tableName} WHERE deptID=%s")
     results = DBConnect.getall(query, (deptID, ))
     objs = []
     for result in results:
         objs.append(cls._rowToObj(result))
     return objs
 def get(cls, deptID):
     query = f"SELECT * FROM {cls.tableName} WHERE {cls.keyName}=%s"
     return cls._rowToObj(DBConnect.getone(query, (deptID, )))
 def add(cls, obj):
     query = f"INSERT INTO {cls.tableName} VALUES (%s, %s, %s, %s)"
     DBConnect.sets(query, obj.toTuple())
Пример #6
0
 def update(cls, obj):
     query = (f"UPDATE {cls.tableName} "
              "SET name=%s, balance=%s, email=%s, phone=%s "
              f"WHERE {cls.keyName}=%s")
     params = (obj.name, obj.balance, obj.email, obj.phone, obj.uid)
     DBConnect.sets(query, params)
 def getByUsername(cls, username):
     query = f"SELECT * FROM {cls.tableName} WHERE username=%s"
     return cls._rowToObj(DBConnect.getone(query, (username, )))
 def update(cls, user):
     query = (f"UPDATE {cls.tableName} "
              "SET username=%s, hashPassword=%s, utype=%s "
              f"WHERE {cls.keyName}=%s")
     params = ()
     DBConnect.sets(query, params)
 def get(cls, uid):
     query = f"SELECT * FROM {cls.tableName} WHERE {cls.keyName}=%s"
     row = DBConnect.getone(query, (uid, ))
     return cls._rowToObj(row)
 def update(cls, obj):
     query = (f"UPDATE {cls.tableName} "
              "SET name=%s, deptID=%s "
              f"WHERE {cls.keyName}=%s")
     params = (obj.name, obj.deptID, obj.uid)
     DBConnect.sets(query, params)