Oops, the line user_data = user.get('USERID') should have read
user_data = user_query.get('USERID')
For now, we're just going to stick with calling "session.refresh"
after each get. Thanks for the help.
-David
On Jun 1, 11:08 pm, Michael Bayer <[email protected]> wrote:
> On Jun 1, 2010, at 1:14 AM, David wrote:
>
>
>
> > Thanks for the response, Michael. Sorry, I forgot to mention how we
> > are committing the data. Here is a skinned-down version of the code
> > that returns "old" data when switching between web servers.
>
> > engine = sqlalchemy.create_engine(ALCHEMY_DATABASE)
> > Session = sqlalchemy.orm.sessionmaker(bind=engine)
> > session = Session()
> > session.expire_all()
>
> > user_query = session.query(User)
> > user_data = user.get('USERID')
> > #session.refresh(user_data) <--- this seems to fix the problem
>
> > try:
> > user_data.var = user_data.var + 1
> > session.add(user_data)
> > session.commit()
> > except:
> > session.rollback()
>
> > class User(Base):
>
> > __table__ = Table('user', Base.metadata,
> > Column('user_id', String(10), primary_key=True),
> > Column('var', Integer, default=0, server_default='0'),
> > mysql_engine='InnoDB'
> > )
>
> > Interestingly enough, adding "session.refresh(user_data)" right after
> > the "get" seems to be fixing the problem. But I'm confused, since I
> > thought "session.expire_all()" should have the same effect. I don't
> > want to add a "refresh" after every get in our code, since I'm afraid
> > it might require multiple calls to the database.
>
> the expire_all has the same effect, yes. You'd need to reproduce your
> behavior in an isolated test case to illustrate what you're doing. For
> example I see a "user.get()" up there, would need to know what that is, etc.
--
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.