async def get_user(request): user_id = request.match_info.get('id', None) logger.debug(user_id) pool = request.app['pool'] # Take a connection from the pool. async with pool.acquire() as connection: # # Open a transaction. # async with connection.transaction(readonly=True): # Run the query passing the request argument. result = await connection.fetchrow( 'SELECT * FROM accounts_user WHERE id=$1', user_id) if result: logger.debug(result) user = User(dict(result.items())) return Response(user.to_primitive()) return Response(status=status.HTTP_404_NOT_FOUND)