title: AttributeError: 'Session' object has no attribute 'session'
body: <p>I am creating an endpoint that will effect a reversal using fastApi with python.I have an endpoint that takes in an id via post request &amp; calls a reverse function on the transaction model. But I get the error AttributeError: 'Session' object has no attribute 'session' on 'db.session.add(transaction)' . I am not sure where this is coming from.</p>
  <p><strong>Transaction model</strong></p>
  <pre><code>class Transaction(Base):
      __tablename__ = &quot;transactions&quot;
      id = Column(Integer, primary_key=True, index=True)
      uuid = Column(UUID(as_uuid=True), nullable=False, default=uuid.uuid4)
      amount = Column(Numeric(18, 2))
      type = Column(
          Enum(TransactionTypes, name=&quot;transaction_trans_types&quot;), nullable=False
      )
      wallet_type = Column(
          Enum(WalletTypes, name=&quot;transaction_wallet_types&quot;), nullable=False
      )
      created_when = Column(DateTime(timezone=True), server_default=func.now())
      payment_ref = Column(String, nullable=False)
      running_balance = Column(Numeric(18, 2))
      currency = Column(String, default=&quot;KES&quot;)
      notes = Column(String)
      paid_by = Column(UUID(as_uuid=True), ForeignKey(&quot;patients.uuid&quot;), nullable=True,)
      patient_uuid = Column(UUID(as_uuid=True), ForeignKey(&quot;patients.uuid&quot;))
      wallet_uuid = Column(UUID(as_uuid=True), ForeignKey(&quot;wallets.uuid&quot;))
      paid_by_names = Column(String)
  
      def reverse(self,db: Session,notes:str =None,):
          transaction =Transaction(amount =self.amount,type= self.type,wallet_type = self.wallet_type,payment_ref = self.payment_ref,
          notes= notes )
          
          db.session.add(transaction)
          db.session.commit()
          db.session.refresh(transaction)
  
          reversal = Reversal(transaction_uuid=transaction.uuid,reversed_transaction_uuid= self.reversed_transaction_uuid)
          db.session.add(reversal)
          db.session.commit()
          db.session.refresh(reversal)
  
          return transaction
  
  </code></pre>
  <p><strong>Reversal Model</strong></p>
  <pre><code>class Reversal(Base):
      __tablename__ = &quot;reversals&quot;  
      id = Column(Integer, primary_key=True, index=True)
      transaction_uuid = Column(UUID(as_uuid=True), ForeignKey(&quot;transactions.uuid&quot;))
      reversed_transaction_uuid = Column(UUID(as_uuid=True),ForeignKey(&quot;transactions.uuid&quot;))
  
      __table_args__ = (
          UniqueConstraint(&quot;reversed_transaction_uuid&quot;),
      )
  
  </code></pre>
  <p><strong>Endpoint</strong></p>
  <pre><code>@router.post(&quot;/{transaction_id}/reverse&quot;,)   
  async def reverse_transaction(
      *,
      db: Session = Depends(deps.get_db),
      transaction_id: int,
      current_user: models.User = Depends(deps.get_current_active_user),
  ) -&gt; Any:
      &quot;&quot;&quot;
      Reverse transaction
      &quot;&quot;&quot; 
      if not current_user.is_superuser:
          raise HTTPException(
              status_code=status.HTTP_403_FORBIDDEN,
              detail=&quot;Not allowed to reverse transactions&quot;,
          )
      try:
          transaction = (
              db.query(Transaction).filter(Transaction.id == transaction_id).scalar()
          )
     
          transaction.reverse(db,transaction)
      except NoResultFound:
          raise HTTPException(
              status_code=status.HTTP_404_NOT_FOUND, detail=&quot;Not found&quot;,
          )    
  
      return transaction    
  </code></pre>
  <p>This is my deps.db</p>
  <pre><code>def get_db() -&gt; Generator:
      try:
          db = SessionLocal()
          yield db
      finally:
          db.close()
  
  </code></pre>