INTERFACE PYTHON WITH SQL VIVA
1. What is the role of the execute() method in Python SQL interface?
Answer:
The execute() method is used to run a SQL query. It can be used for SELECT, INSERT, UPDATE, DELETE, or any other SQL command.
2. Explain how to update records in an SQL database using Python.
Answer:
To update records, you can use the UPDATE SQL command within the execute() method, followed by commit() to save the changes.
3. What is the difference between fetchall() and fetchone() in Python SQL interface?
Answer:
fetchall(): Returns all rows of the result set as a list of tuples.fetchone(): Returns only the first row of the result set as a tuple.