How is a query execution defined? Is Session.save_or_update()
classified as a query execution? I expected an autoflush to occur on
each call to save_or_update.



On Jul 2, 1:09 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Jul 2, 2008, at 3:20 PM, andres wrote:
>
>
>
>
>
> > Hi,
>
> > I'm just starting out with SQLAlchemy and I encountered some
> > unexpected behavior with autoflush and mysql. I expected that setting
> > autoflush=True would force a flush after every DB call. However, it
> > seems that a flush isn't happening automatically on an add/delete.
>
> > Here is my test script:
> > ##
> > mysqlflush.py
> > import sqlalchemy as sa
> > from sqlalchemy import orm
>
> > metadata = sa.MetaData()
>
> > tmptable_table = sa.Table('TmpTable', metadata,
> >                          sa.Column('id', sa.types.Integer,
> > primary_key=True),
> >                          sa.Column('val', sa.types.String(100),
> > nullable=False)
> >                          )
>
> > class TmpTable(object):
> >    def __init__(self,val):
> >    self.val = val
>
> > orm.mapper(TmpTable, tmptable_table)
>
> > engine = sa.create_engine('mysql://user:[EMAIL PROTECTED]:3306/
> > test_db',  echo=True)
> > metadata.create_all(engine)
> > Session = orm.sessionmaker(bind=engine, autoflush=True,
> > transactional=True)()
>
> > for i in range(0,100,1):
> >    Session.save_or_update(TmpTable(val='blah'))
>
> > The results of running the test script are:
> > mysql> select * from test_db.TmpTable;
> > Empty set (0.00 sec)
>
> the session flushes on every commit(), and when autoflush=True on  
> every Query execution as well.
--~--~---------~--~----~------------~-------~--~----~
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