Please disregard this; I've solved it.
On Fri, Dec 9, 2011 at 11:18 AM, Noon Silk <[email protected]> wrote: > I can't figure out how. > > I have the following setup: > > ... > engine = create_engine("...") > session = scoped_session(sessionmaker(..., bind=engine)) > > ... > > session.add(object) > session.commit() > > > What I need is to "add" this object *to the database*, and then select > it in some non-sql-alchemy code, and then after that, I want to not > commit it; (or rollback, whatever the model is). > > This doesn't seem possible when using objects in this fashion. I note > that there is this concept of begin transaction on a connection > object, but SQLAlchemy doesn't seem to respect this, when I commit the > session, as per above. Because, of course, calling .add on the session > accomplishes exactly nothing from a db point of view (it doesn't even > update the primary key). > > I attempted to wrap the session in a connection transaction with the > following: > > ... > connection = engine.connect() > transaction = connection.begin() > > .. add/commit on session > > transaction.rollback() > > This still resulted in the entity being added to the database. There > must be a way to accomplish this; can someone please let me know what > I have missed? > > -- > 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. > -- Noon Silk Fancy a quantum lunch? http://groups.google.com/group/quantum-lunch?hl=en "Every morning when I wake up, I experience an exquisite joy — the joy of being this signature." -- 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.
