def get_user(self, user_id): cursor = self.db.cursor() cursor.execute('SELECT id, name, creation_time FROM users WHERE id=%s', [user_id]) rows = cursor.fetchall() if rows and len(rows) > 0: user = UserData.User() user.id, user.name, user.creation_time = rows[0] return user else: return None
def get_all_users(self): cursor = self.db.cursor() cursor.execute('SELECT id from users') rows = cursor.fetchall() result = [] if rows and len(rows) > 0: for row in rows: user = UserData.User() user.id = row[0] user.emails = self.get_emails(user.id) result.append(user) return result