def get(self, id): cur = self.db.cursor() user = None psycopg2.extras.register_uuid() try: cur.execute("SELECT * FROM public.users \ WHERE id = %s", (id,)) row = cur.fetchone() # build the user object # get the user id & convert it to python UUID type user = User() user.id = row[0] user.name = row[1] user.email = row[2] user.password = row[3] except Exception as e: print "An error occurred while reading user id" print e raise e finally: # return user object cur.close() return user