On May 9, 2008, at 12:02 PM, David Turner wrote:
>
> page = Page (url = url, body = body)
> Session.insert_or_update(page)
> Session.commit()
>
> Is this functionality there, and I just don't understand it?
here is the usual way:
page = Session.query(Page).filter(Page.url == url,
Page.body==body).first()
if not page:
page = Page(url = url, body=body)
session.save(page)
If you know the primary key identifiers of the object, you may also
use merge():
page = Page(<primary key identifiers>)
persisted_page = Session.merge(page)
the latter will do the same thing automatically as the former (SQLA
does not use IntegrityErrors to query the database).
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---