Computer Science
Explain the transaction keywords used with MySQL-Python connectivity.
Python MySQL
2 Likes
Answer
The 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.autocommit
value 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.
Answered By
1 Like