commit() is required to be used after the execution of certain queries in…
2023
commit() is required to be used after the execution of certain queries in Python-MySQL connectivity applications. Identify one such MySQL command out of the following options: Python-MySQL
- A.
(CREATE / CREATE
- B.
INSERT / INSERT
- C.
SELECT / SELECT
- D.
DROP / DROP
Attempted by 1053 students.
Show answer & explanation
Correct answer: B
In Python-MySQL connectivity, the commit() function is used to save changes made by Data Manipulation Language (DML) commands to the database. DML commands such as INSERT, UPDATE, and DELETE modify data and require an explicit commit() to make the changes permanent. On the other hand, Data Definition Language (DDL) commands like CREATE, ALTER, and DROP modify the database structure and are automatically committed in MySQL. SELECT commands are used to retrieve data and do not change the database state, so they do not require commit(). Therefore, the command that requires commit() is one that modifies data.