CBSE Class 12 Computer Science
Question 27 of 47
Interface Python with SQL — Question 5
Back to all questionsThe transaction keywords used with MySQL-Python connectivity are as follows:
- commit — The COMMIT keyword is used to permanently apply the changes made during a transaction to the database. The
MySQLConnection.commit()method sends a COMMIT statement to the MySQL server, finalizing and committing the current transaction. It's important to commit transactions only when all operations within the transaction have been successfully completed and verified. - rollback — The ROLLBACK keyword is used to undo or revert changes made during a transaction. When a transaction fails to execute and we want to revert all the changes, the
MySQLConnection.rollback()method can be used to revert the changes. - autocommit — The
MySQLConnection.autocommitvalue can be assigned as True or False to enable or disable the auto-commit feature of MySQL. By default, its value is False. This feature controls whether each SQL statement is automatically committed as a separate transaction or if manual transaction control is required.