- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Performing Database Transactions using Python
Transactions are a mechanism that ensures data consistency. Transactions have the following four properties −
- Atomicity − Either a transaction completes or nothing happens at all.
- Consistency − A transaction must start in a consistent state and leave the system in a consistent state.
- Isolation − Intermediate results of a transaction are not visible outside the current transaction.
- Durability − Once a transaction was committed, the effects are persistent, even after a system failure.
The Python DB API 2.0 provides two methods to either commit or rollback a transaction.
You already know how to implement transactions. Here is again similar example −
# Prepare SQL query to DELETE required records sql = "DELETE FROM EMPLOYEE WHERE AGE > '%d'" % (20) try: # Execute the SQL command cursor.execute(sql) # Commit your changes in the database db.commit() except: # Rollback in case there is any error db.rollback()
- Performing Google Search using Python code?
- Performing multiple transitions using CSS3
- Automating SAP Transactions/actions using SAP GUI
- Querying SAP database using Python
- Longest Well-Performing Interval in Python
- Performing Null check using HANA SQL Script
- Invalid Transactions in C++
- Performing white TopHat operation on images using OpenCV
- Performing white BlackHat operation on images using OpenCV
- Performing binary thresholding on an image using OpenCV
- Performing truncate thresholding on an image using OpenCV
- Performing zero thresholding on an image using OpenCV
- Performing an opening operation on an image using OpenCV
- Performing a closing operation on an image using OpenCV
- Performing inverse binary thresholding on an image using OpenCV