I want to select specific values from a table, by looking at the code from SQLAlchemy session.py
def query(self, *entities, **kwargs):
"""Return a new ``Query`` object corresponding to this ``Session``."""
return self._query_cls(entities, self, **kwargs)
it does seem that as a function parameter, it accepts a tuple. So what I did was:
query = ('order', 'location')
columnsStr = 'order, location'
table = 'locations'
sql = "SELECT {0} FROM {1}".format(columnsStr, table)
data = session.query(query).from_statement(sql).all()
And it produces this error - InvalidRequestError: SQL expression, column, or mapped entity expected - got '('order', 'location')'
Why doesn't this work with a tuple?
P.S.
If I change the values of these:
query = 'location'
columnsStr = 'location'
I do get a result, but only for that single column.