Difference between revisions of "SQLAlchemy Notes"
Jump to navigation
Jump to search
PeterHarding (talk | contribs) (→Joins) |
PeterHarding (talk | contribs) |
||
Line 31: | Line 31: | ||
[[Category | [[Category:SQLAlchemy]] | ||
[[Category | [[Category:Flask]] |
Revision as of 09:51, 31 May 2017
Joins
From PIQ_Admin /CRM/Contacts
sql = select([Contact.Contact_ID, Contact.FirstName, Contact.LastName, Contact.Phone, Contact.MobilePhone, Contact.Account_FK, Account.Name])\ .where(Contact.Account_FK == Account.Account_ID).order_by(Contact.LastName, Contact.FirstName) ctx.Contacts = db.session.execute(sql)
Failed experiments:
# ctx.Contacts = Contact.query.filter_by(Owner_FK=ctx.User.User_ID).all() # j = join(Contact, Account, Contact.Account_FK == Account.Account_ID) # stmt = db.session.execute(select([Contact.Contact_ID, Account.Account_ID])).select_from(j)
filter_by() vs. filter()
Links:
- a