It does indeed! It is my bad, it works as expected, the problem was due to not flushing properly before storing the values in the dictionary.
Sorry for the inconvenience and thank you for the support. On Nov 9, 4:46 pm, Mike Conley <mconl...@gmail.com> wrote: > Using your class definitions, it seems to work. What is different? > > Base.metadata.bind=create_engine('sqlite:///') > Base.metadata.create_all() > session=sessionmaker()() > bk_ids = {} > for title in ('Tom Sawyer', 'Huck Finn'): > book = Book(title=title) > session.add(book) > session.flush() > bk_ids[title] = book.id > session.commit() > print bk_ids > > for i, content in enumerate(( > 'Once upon a time there was a little fellow called Tom.', > 'His surname was Sawyer.')): > page = Page(i, content, bk_ids['Tom Sawyer']) > session.add(page) > session.commit() > > for page in session.query(Page): > print 'page:',page.id,' book:',page.book_id --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---