title: FastAPI AttributeError: 'job_board' object has no attribute 'query'
body: <p>I'm trying to build a simple job board using Python, FastAPI and Async sqlalchemy by following the official FastAPI documentation.Problem occurring when I try to retrieve the job by the <code>ID</code> from the database, It's keep giving me this error <code>AttributeError: 'job_board' object has no attribute 'query'</code> when I hit the <code>&quot;/get/{id}&quot;</code>endpoint.</p>
  <p>The Following is hopefully a minimum reproducible code segment:</p>
  <p><strong>schemas/jobs.py</strong></p>
  <pre><code>from typing import Optional
  from pydantic import BaseModel
  from datetime import date, datetime
  
  
  class JobBase(BaseModel):
      title: Optional[str] = None
      company_name: Optional[str] = None
      company_url: Optional[str] = None
      location: Optional[str] = &quot;remote&quot;
      description: Optional[str] = None
      date_posted: Optional[date] = datetime.now().date()
  
  class JobCreate(JobBase):
      title: str
      company_name: str
      location: str
      description: str
  
  class ShowJob(JobBase):
      title: str
      company_name: str
      company_url: Optional[str]
      location: str
      date_posted: date
      description: str
  
      class Config():
          orm_mode = True
  </code></pre>
  <p><strong>routes/route_jobs.py</strong></p>
  <pre><code>from fastapi import APIRouter, HTTPException, status
  from fastapi import Depends
  from sqlalchemy.orm.session import Session
  
  from db.repository.job_board_dal import job_board
  from db.models.jobs import Job as model_job
  from schemas.jobs import JobCreate, ShowJob
  from db.repository.job_board_dal import Job
  from depends import get_db
  
  router = APIRouter()
  
  @router.post(&quot;/create-job&quot;,response_model=ShowJob)
  async def create_user(Job: JobCreate, jobs: Job = Depends(get_db)):
      owner_id = 1
      return await jobs.create_new_job(Job, owner_id)
  
  @router.get(&quot;/get/{id}&quot;)
  def retreive_job_by_id(id:int, session: Session = Depends(get_db)):
      #print(type(session))
      job_id = job_board.retrieve_job(session, id=id)
      if not job_id:
          HTTPException(status_code=status.HTTP_404_NOT_FOUND,
          detail=f&quot;Job with id {id} does not exist&quot;)
      return job_id
  </code></pre>
  <p><strong>db/repository/job_board_dal.py</strong></p>
  <pre><code>from sqlalchemy.orm import Session
  
  from schemas.users import UserCreate
  from schemas.jobs import JobCreate
  from db.models.users import User
  from db.models.jobs import Job
  from core.hashing import Hasher
  
  
  
  class job_board():
      def __init__(self, db_session: Session):
          self.db_session = db_session
  
      async def register_user(self, user: UserCreate):
          new_user = User(username=user.username,
          email=user.email,
          hashed_password=Hasher.get_password_hash(user.password),
          is_active = False,
          is_superuser=False
          )
          self.db_session.add(new_user)
          await self.db_session.flush()
          return new_user
  
      
      async def create_new_job(self, job: JobCreate, owner_id: int):
          new_job = Job(**job.dict(), owner_id = owner_id)
          self.db_session.add(new_job)
          await self.db_session.flush()
          return new_job
  
      def retrieve_job(db: Session, id:int):
          item = db.query(Job).filter(Job.id == id).first()
          return item
  </code></pre>
  <p><strong>depends.py</strong></p>
  <pre><code>from db.session import async_session
  from db.repository.job_board_dal import job_board
  
  async def get_db():
      async with async_session() as session:
          async with session.begin():
              yield job_board(session)
  </code></pre>
  <p>I did try a lot of things I even try to retrieve with a separate async session which also gives me the AttributeError: 'AsyncSession' object has no attribute 'query'.
  Any help would be much appreciated.</p>