SQLAlchemy のコードを見て、テーブルから特定の値を選択したいsession.py
def query(self, *entities, **kwargs):
"""Return a new ``Query`` object corresponding to this ``Session``."""
return self._query_cls(entities, self, **kwargs)
関数パラメーターとしてtuple を受け入れるようです。だから私がしたことは:
query = ('order', 'location')
columnsStr = 'order, location'
table = 'locations'
sql = "SELECT {0} FROM {1}".format(columnsStr, table)
data = session.query(query).from_statement(sql).all()
そして、このエラーが発生します-InvalidRequestError: SQL expression, column, or mapped entity expected - got '('order', 'location')'
これがタプルで機能しないのはなぜですか?
PS
これらの値を変更すると:
query = 'location'
columnsStr = 'location'
結果は得られますが、その単一の列に対してのみです。