programmer.py wrote:
>
> So, the s2 query is `cached`?  I'm still confused about this.
>
> Whenever I issue a rollback() on s2, like you described, it works.
> I'm just surprised, because I expected the query to always fetch fresh
> results.  Should I not be surprised?

here's some background:

http://en.wikipedia.org/wiki/Isolation_%28database_systems%29

and

http://dev.mysql.com/doc/refman/5.1/en/innodb-consistent-read.html




>
> Thanks for your help!
> jw
>
>
>>
>> > # Begin python script
>> > import sys
>> > from sqlalchemy.ext.declarative import declarative_base
>> > from sqlalchemy import Column, Integer, String, create_engine
>> > from sqlalchemy.orm import sessionmaker
>>
>> > Base = declarative_base()
>>
>> > class SimpleTest(Base):
>> >     __tablename__ = 'simpletest'
>>
>> >     id = Column(Integer, primary_key=True)
>> >     s1 = Column(String(255))
>>
>> > def main():
>> >     engine1 = create_engine('mysql://test:t...@localhost/test')
>> >     engine2 = create_engine('mysql://test:t...@localhost/test')
>> >     SimpleTest.metadata.create_all(engine1)
>>
>> >     # Clear out the test table.
>> >     con = engine1.connect()
>> >     con.execute('TRUNCATE simpletest')
>>
>> >     # Create two distinct sessions.
>> >     s1 = sessionmaker(bind=engine1)()
>> >     s2 = sessionmaker(bind=engine2)()
>>
>> >     # Show empty table count on session 2.
>> >     print s2.execute('SELECT COUNT(*) FROM simpletest').scalar()
>>
>> >     # Load the database with 10 rows.
>> >     for x in range(10):
>> >         st = SimpleTest()
>> >         st.s1 = str(x)
>> >         s1.add(st)
>> >     s1.commit()
>>
>> >     print s1.execute('SELECT COUNT(*) FROM simpletest').scalar()
>> >     print s2.execute('SELECT COUNT(*) FROM simpletest').scalar()
>>
>> > if __name__ == '__main__':
>> >     sys.exit(main())
>>
>> > Thanks,
>> > jw
>>
>> > --
>> > 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.
>
> --
> 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.
>
>

-- 
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.

Reply via email to