Midgard2 and database transactions
Posted on 2009-07-07 14:34:02 EEST.
Mjolnir has a very nice feature, which many Midgard developers has been waiting for, for long time. Introduced midgard_transaction class provides an easy way to manage database transactions. I was wondering if transaction support should be implemented as midgard_connection methods, but I decided not to abuse connection's API and transaction class as standalone one would emit (in a future) additional signals for applications' callbacks.
midgard_transaction usage is very easy:
t = midgard.transaction()
t.begin()
t.commit()
The same API works in C, PHP and also in Objective-C Midgard bindings. Note that Midgard core itself never uses transactions. It's up to the application, whether begin, commit or rollback transaction.
I also found some issue related to SQLite transaction's identifier. If you think it could be solved better way, let us know.