Sunday 12 June 2016

Python: MySQLdb: Transaction support

Transaction is unit of work performed in database management system against a database.

Example
1. Transferring money from Account A to Account B
2. Booking a Movie ticket

A database transaction satisfies properties like Atomicity, consistency, Isolation, Durability,

a. Atomicity
A Transaction performed on a database must complete fully or have no effect. Suppose transferring money from account 'A' to account 'B' must performed completely. It shouldn't be in middle state like money deducted from Account 'A' and not credited to account 'B'.

b. Consistency
The guarantee that operations in transactions are performed accurately, correctly, and with validity, with respect to application semantic.

c. Isolation
Even though transactions can execute concurrently, it appears to each transaction that others executed either before or after it.

d. Durability
Transactions that have committed will survive permanently on any circumstances like system crash also.


Python DB API provides two methods commit, rollback for transaction support.



Previous                                                 Next                                                 Home

No comments:

Post a Comment