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)
Am I just not understanding autoflush correctly?
Thanks,
Andres
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---