Michael,
Thank you for answering. The following is what I tried in order to
follow your advise:
account_summaries = select(
[
transactions.c.account_id,
func.max(transactions.c.processed_at).label('last_used'),
func.count(transactions.c.id).label('times_used'),
],
group_by=[transactions.c.account_id],
).alias('account_summaries')
class AccountSummary(object):
pass
account_summary_mapper = mapper(Account, account_summaries,
non_primary=True)
account_mapper = mapper(Account, accounts,
properties={
'summary': relation(AccountSummary, lazy=True, viewonly=True,
primaryjoin=(accounts.c.id==account_summary.c.account_id)),
},
)
But it raises the following exception when I try to instantiate
Account class:
ArgumentError: Could not assemble any primary key columns for mapped
table 'account_summary'
What am I doing wrong?
Thanks again for your help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---