title: Creating Dynamic Select Query in SqlAlchemy
body: <p>I have researched this topic and have decided just to ask here since I can't seem to find anything. I'll explain below:</p>
  
  <p>Context: Flask Application with a form the client fills out and posts to the server. The form inputs are used to create a query and return data.</p>
  
  <p>I am using SQLalchemy currently to construct the query from scratch. At this point, I have successfully connected to my existing Redshift database and can query properly but I cannot figure out how to dynamically construct a simple <code>Select x, y, z</code> statement based on the user's form inputs.</p>
  
  <p>The main problem being that <code>Query()</code> can't take in a python list of columns. It seems you must specify each column like <code>table.c.column1</code> which doesn't work well with a dynamic query since I don't know what columns I want until the user submits the form.</p>
  
  <p>My 2 ideas so far:</p>
  
  <ol>
  <li>Loop through all column names and use <code>Query.add_columns(table.c['colname'])</code></li>
  <li>Use <code>select([col1, col2, ...])</code> instead of <code>Query()</code></li>
  <li>Use <code>load_columns()</code> to load only specific columns in a table to query. Unfortunately seems to only work with model objects and not reflected tables unless I am mistaken</li>
  </ol>
  
  <p>Both of these seem backwards to me as they do not really accomplish my goal effectively.</p>