Exam4Training

Select the true statements about the sqlite3 module. (Select two answers.)

Select the true statements about the sqlite3 module. (Select two answers.)
A . The fetchalt method returns None when no rows are available
B. The execute method allows you to perform several queries at once
C. The execute method is provided by the Cursor class
D. The fetchone method returns None when no rows are available

Answer: C,D

Explanation:

C. The execute method is provided by the Cursor class

This statement is true because the execute method is one of the methods of the Cursor class in the sqlite3 module. The Cursor class represents an object that can execute SQL statements and fetch results from a database connection. The execute method takes an SQL query as an argument and executes it against the database. For example, cur = conn.cursor (); cur.execute (“SELECT * FROM table”) creates and executes a cursor object that selects all rows from a table.

D. The fetchone method returns None when no rows are available

This statement is true because the fetchone method is another method of the Cursor class in the sqlite3 module. The fetchone method fetches the next row of a query result set and returns it as a single tuple or None if no more rows are available. For example, row = cur.fetchone () fetches and returns one row from the cursor object or None if there are no more rows.

Exit mobile version