title: python: flask-sqlalchemy combine filter_by and _in
body: <p>Following the example in <a href="https://stackoverflow.com/questions/19506105/flask-sqlalchemy-query-with-keyword-as-variable">this question</a> I have a little <code>flask</code> view that filters data based on querystring arguments:</p>
  
  <pre><code>@app.route('/regs')
  def regs_data():
  
      #check what data is available
      #REGS is a sqlalchemy model
      cols = REGS.__table__.columns.keys()
  
      kwargs = {}
      for k, v in request.args.lists():
          if k not in cols:
              abort(400, "helpful err msg")
  
          #takes only first occurrence
          kwargs[k]=v[0]
  
      my_query = REGS.query.filter_by(**kwargs).all()
  
      #....modify the query data for return
  
      return the_data_as_json
  </code></pre>
  
  <p>This works great for when there is only 1 occurence of each key in <code>request.args</code>. How can I extend this to cope with multiple values for each keyword? e.g <code>/regs?foo=1&amp;foo=2</code></p>
  
  <p>Is there a way to apply both <code>filter_by</code> and <code>in_()</code></p>
  
  <p>Thanks</p>