I've been using
http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons
to help with the migration because the migration tutorial on
SQLAlchemy (http://www.sqlalchemy.org/docs/04/
intro.html#overview_migration) only included a partial list of things
that I would need to change in my app.
I finally got the app working with selects (I can view different
categories, etc.). However, write queries to the database is a
different story.
While following the tutorial I'm defining a transactional connection
as follows:
sm = orm.sessionmaker(autoflush=True, transactional=True,
bind=engine)
As the tutorial says, sometimes you use save(), like when creating a
new instance, and other times you don't, like when doing updates.
I've been trying different combinations of the code below, but keep
getting the following error (where XXX is a random number):
InvalidRequestError: Instance '[EMAIL PROTECTED]' is already persistent
heading = Heading('Text')
heading.page = page_object
heading.user_id = '1'
meta.Session.save(heading)
# get new id
heading_id = heading.heading_id
# Save note
note = Note('Foobar')
note.heading_id = heading_id
# cascade update dates up
note.heading.page.last_mod_date = func.now()
note.heading.page.notebook.last_mod_date = func.now()
meta.Session.commit()
Any ideas? Need more info?
Thanks in advance!
John
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---