title: Why do I get NameError for the column that is defined in SQLAlchemy model
body: <p>I am developing REST APIs with Flask. One of the tables is modeled as follows:</p>
  
  <pre><code>class AudioSessionModel(db.Model):
      __tablename__ = 'audio_session'
      id = db.Column('audio_session_id', db.Integer, primary_key = True)
      cs_id = db.Column(db.Integer)
      session_id = db.Column(db.Integer)
      facility = db.Column(db.Integer)
      description = db.Column(db.String(400))
  
      def __init__(self, cs_id, session_id, facility):
          self.cs_id = cs_id
          self.session_id = session_id
          self.facility = facility
  </code></pre>
  
  <p>Business logics are defined in a DAO class:</p>
  
  <pre><code>class AudioSessionDAO(object):
      def update(self, data):
          audio = AudioSessionModel.query.filter(cs_id == data['CSID'], session_id == data['Session'])
          audio.description = data['Desc']
          db.session.commit()
          return audio
  </code></pre>
  
  <p>This <code>upate</code> function is called in my endpoint for <code>PUT</code> request:</p>
  
  <pre><code>@api.route('/OperatorAccessment')
  class OperatorAssessment(Resource):
  
      @api.expect(assessment)
      def put(self):
          as_dao = AudioSessionDAO()
          as_dao.update(request.json)  
  </code></pre>
  
  <p>The model <code>assessment</code> looks like this:</p>
  
  <pre><code>assessment = api.model('Operator Assessment', {
      'CSID': fields.Integer(required=True, description='Central Station ID'),
      'Session': fields.Integer(required=True, description='Session ID'),
      'Desc': fields.String(description='Description')
  })
  </code></pre>
  
  <p>When I test the <code>PUT</code> request with the following json in request body:</p>
  
  <pre><code>{
     "CSID": 1,  
     "Session": 1, 
     "Desc": "Siren"
   } 
  </code></pre>
  
  <p>I got the following error:</p>
  
  <pre><code>  File "C:\Users\xxx_app\model\dao.py", line 63, in update
      audio = AudioSessionModel.query.filter(cs_id == data['CSID'], session_id == data['Session'])
  NameError: name 'cs_id' is not defined
  </code></pre>
  
  <p>Apparently, <code>cs_id</code> is defined. Why am I still getting this error?</p>