Hi All, I am joining 3 tables in SQLAlchemy Core and selecting all columns as follows:
rows = self.db.execute(self.execs.join( self.orders.join(self.instruments) ).select(whereClause)).reduce_columns()) It works well but if I want to select a subset of columns: reqdCols = [order.c.id, exec.c.last_modified, instruments.type] rows = self.db.execute(self.execs.join( self.orders.join(self.instruments) ).select(reqdCols, whereClause)).reduce_columns()) It doesn't works and gives following error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/apps/qtdist/pkgs/pub/cpython/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/sql/selectable.py", line 807, in select return Select(collist, whereclause, from_obj=[self], **kwargs) File "/apps/qtdist/pkgs/pub/cpython/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/sql/selectable.py", line 2219, in __init__ whereclause).self_group(against=operators._asbool) File "/apps/qtdist/pkgs/pub/cpython/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 3438, in _literal_as_text "SQL expression object or string expected." sqlalchemy.exc.ArgumentError: SQL expression object or string expected. Alternative would be to use select instead of Join.select and make it implicit join with where clauses: joinConditions = (orders.c.colx == execs.colx) & (execs.c.coly == instruments.c.coly) select(reqdCols).where(and_(whereClause, joinConditions) But I would prefer explicit join over implicit for performance reasons. Is there any way to select subset of columns using explicit joins? Regards, Apoorv PS: I have post the same in Stack Overflow Question: http://stackoverflow.com/questions/25656935/selecting-columns-from-mulitple-table-join-in-sqlalchemy-core# _______________________________________________ This message is for information purposes only, it is not a recommendation, advice, offer or solicitation to buy or sell a product or service nor an official confirmation of any transaction. It is directed at persons who are professionals and is not intended for retail customer use. Intended for recipient only. This message is subject to the terms at: www.barclays.com/emaildisclaimer. For important disclosures, please see: www.barclays.com/salesandtradingdisclaimer regarding market commentary from Barclays Sales and/or Trading, who are active market participants; and in respect of Barclays Research, including disclosures relating to specific issuers, please see http://publicresearch.barclays.com. _______________________________________________ -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.