I was playing with SqlSoup in preparation to use it in a new (production)
project (sqlalchemy version 0.5.0beta3).  I was testing with MySQL InnoDB
tables.  The SqlSoup wiki page,  and source code docstring,  imply that a
SqlSoup.flush() will commit the data.  I quickly realized that this is NOT
the case when using transactional InnoDB tables  as shown below (although
non-transactional ISAM tables work fine).

Note that if I execute sqlsoup.Session.configure(autocommit = True)
everything works as expected.  Please correct me if I have this wrong,  this
is my first time using SqlSoup.

Assuming that the explicit commits ARE needed (i.e. I am not doing something
wrong), then I think that the wiki page and doc string should be fixed to
clarify this issue.  I also think it would be a good idea to include
.commit,  .rollback,  and .begin methods on the SqlSoup class as I did
below.

Note,  I WANT to explicitly issue the .commit's,  so I hope I am
understanding this correctly.  I just need some clarification.  I cannot
find much recent information on SqlSoup by searching this list.  Is it
supported? Is it used? Can it be used in a production environment?

Thanks,

Shawn Church
I/S Consultant
Shawn At SChurchComputers.com

=== Code ===
from sqlalchemy.ext import sqlsoup

class SqlSoup(sqlsoup.SqlSoup):

    def begin(self, *args, **kw):
        return sqlsoup.Session.begin(*args, **kw)

    def commit(self, *args, **kw):
        return sqlsoup.Session.commit(*args, **kw)

    def rollback(self, *args, **kw):
        return sqlsoup.Session.rollback(*args, **kw)


if __name__ == "__main__":
    db = SqlSoup("mysql://xxxx:[EMAIL PROTECTED]/test")
    Test = db.test # Get the table def w/o echo

    print "This does NOT commit:"
    db.bind.echo = True
    Test.insert()
    db.flush()

    print "\nBut this will commit both inserts"
    Test.insert()
    db.commit()

=== Output ===
 /usr/bin/python /home/schurch/Projects/testsoup/testsoup2.py
This does NOT commit:
2008-08-29 22:47:43,032 INFO sqlalchemy.engine.base.Engine.0x..6c BEGIN
2008-08-29 22:47:43,036 INFO sqlalchemy.engine.base.Engine.0x..6c INSERT
INTO test () VALUES ()
2008-08-29 22:47:43,036 INFO sqlalchemy.engine.base.Engine.0x..6c []

But this will commit both inserts
2008-08-29 22:47:43,043 INFO sqlalchemy.engine.base.Engine.0x..6c INSERT
INTO test () VALUES ()
2008-08-29 22:47:43,044 INFO sqlalchemy.engine.base.Engine.0x..6c []
2008-08-29 22:47:43,046 INFO sqlalchemy.engine.base.Engine.0x..6c COMMIT
Press <enter> to close window

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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