On Dec 14, 2005, at 7:59 PM, limodou wrote:
1. Is there a easy way to detect a table has exist?
mmmm, you might try saying t = new Table('mytable', engine,
autoload=True) and catch an exception. I didnt build a specific
function for this yet.
2. How to using transaction?
assuming youre just using the SQLEngine with SQL, it has a begin(),
rollback() and commit() method:
engine.begin()
try:
mytable.insert(...).execute()
mytable.insert(...).execute()
except:
engine.rollback()
raise
engine.commit()
you can also say:
def do_stuff():
mytable.insert(..).execute()
engine.transaction(do_stuff)
the begin/commit has a "reentrant" functionality, so nested begin/
commits all work towards the outermost transaction:
def method_a():
engine.begin()
method_b()
engine.commit()
def method_b():
engine.begin()
mytable.insert(...).execute()
mytable.insert(...).execute()
engine.commit()
the begin/commit would happen within the scope of "method_a". the
"method_b" begin/commit has no effect. a rollback within "method_b"
however would rollback the whole thing.
When using the ORM, transactions are handled within the
objectstore.commit() cycle, which is a different idea than
engine.commit(). However, if you do an engine begin/commit as above,
and do objectstore.commit inside that transaction, it will take part
in the larger transaction.
objectstore also has its own begin/commit which works a little
differently from a regular database transaction; within an
objectstore begin/commit, changes to objects are tracked and those
form the objects that will be modified upon objectstore.commit.
objectstore.begin/commit's can also be nested where they remain
independent of each other.
Sorry for the brevity at the moment, I hope to document all this
stuff soon.
Can anyone send me some info? Thanks very much.
I'm learning this module now.
--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through
log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD
SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users