title: AttributeError: 'Blog' object has no attribute 'items' - FastAPI
body: <p>I am trying to update a single record in the database by using the PUT operation in FastAPI. But for some reason, I keep getting this error. All other operations work fine except this one. The error is only raised for the update query.</p>
  <pre><code>AttributeError: 'Blog' object has no attribute 'items'
  </code></pre>
  <p>Here is the relevant code.</p>
  <pre><code>def get_db():
      db = SessionLocal()
      try:
          yield db
      finally:
          db.close()
  
  class Blog(BaseModel):
      title: str
      body: str
  
  @app.put('/blog/{id}', status_code=status.HTTP_204_NO_CONTENT, response_class=Response)
  def update(id: int, request: schemas.Blog, db: Session = Depends(get_db)):
      blog = db.query(models.Blog).filter(models.Blog.id == id)
      if not blog.first():
          raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
                              detail=f'Blog with id {id} not found')
      blog.update(request)
      db.commit()
  </code></pre>
  <p>This is the StackTrace:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\uvicorn\protocols\http\h11_impl.py&quot;, line 396, in run_asgi        
      result = await app(self.scope, self.receive, self.send)
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\uvicorn\middleware\proxy_headers.py&quot;, line 45, in __call__        
      return await self.app(scope, receive, send)
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\fastapi\applications.py&quot;, line 199, in __call__
      await super().__call__(scope, receive, send)
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\starlette\applications.py&quot;, line 111, in __call__
      await self.middleware_stack(scope, receive, send)
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\starlette\middleware\errors.py&quot;, line 181, in __call__
      raise exc from None
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\starlette\middleware\errors.py&quot;, line 159, in __call__
      await self.app(scope, receive, _send)
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\starlette\exceptions.py&quot;, line 82, in __call__
      raise exc from None
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\starlette\exceptions.py&quot;, line 71, in __call__
      await self.app(scope, receive, sender)
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\starlette\routing.py&quot;, line 566, in __call__
      await route.handle(scope, receive, send)
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\starlette\routing.py&quot;, line 227, in handle
      await self.app(scope, receive, send)
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\starlette\routing.py&quot;, line 41, in app
      response = await func(request)
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\fastapi\routing.py&quot;, line 201, in app
      raw_response = await run_endpoint_function(
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\fastapi\routing.py&quot;, line 150, in run_endpoint_function
      return await run_in_threadpool(dependant.call, **values)
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\starlette\concurrency.py&quot;, line 34, in run_in_threadpool
      return await loop.run_in_executor(None, func, *args)
    File &quot;C:\Python39\lib\concurrent\futures\thread.py&quot;, line 52, in run
      result = self.fn(*self.args, **self.kwargs)
    File &quot;.\blog\main.py&quot;, line 66, in update
      blog.update(request)
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\sqlalchemy\orm\query.py&quot;, line 3190, in update
      upd = upd.values(values)
    File &quot;&lt;string&gt;&quot;, line 2, in values
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\sqlalchemy\sql\base.py&quot;, line 96, in _generative
      x = fn(self, *args, **kw)
    File &quot;&lt;string&gt;&quot;, line 2, in values
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\sqlalchemy\sql\base.py&quot;, line 125, in check
      return fn(self, *args, **kw)
    File &quot;c:\dev\fast-tuts\env\lib\site-packages\sqlalchemy\sql\dml.py&quot;, line 701, in values
      for k, v in arg.items()
  AttributeError: 'Blog' object has no attribute 'items'
  </code></pre>