PCPP1 practice question 4 of 10
Select the true statements about the sqirte3 module. (Select two answers.)
Full set: 45 questionsThe sqlite3 module is Python's built-in interface for the SQLite database engine. It is designed to be compliant with the Python Database API Specification 2.0 (PEP 249), which standardizes how Python programs interact with databases. This compliance ensures a consistent API for developers. As part of this specification, the cursor.fetchall() method is required to fetch all remaining rows from a query result. If the query yields no rows, or all rows have already been fetched, the method correctly returns an empty list ([]), providing a predictable way to handle empty result sets.
B. The special filename required to create an in-memory SQLite database is the string ":memory:", not "memory". The leading colon is mandatory.
C. The sqlite3 module fully supports database transactions through the Connection object's commit() and rollback() methods, which are essential for ensuring data integrity.
1. Python 3 Documentation, sqlite3 — DB-API 2.0 interface for SQLite databases.
For A: Section 13.13, Introduction. "This module provides a DB-API 2.0 compliant interface to the SQLite database."
For B: Section 13.13.2.1, sqlite3.connect(). "To use the database in RAM, specify :memory: for database."
For C: Section 13.13.3.2, Connection.commit(). This documents the method for committing the current transaction, confirming transaction support.
For D: Section 13.13.4.5, Cursor.fetchall(). The description states it "fetches all (remaining) rows of a query result, returning a list." This implies an empty list if no rows are available.
2. PEP 249 -- Python Database API Specification v2.0.
For A: Section "Introduction". The entire document specifies the interface that modules like sqlite3 implement.
For D: Section "Cursor Objects", .fetchall(). "Fetch all (remaining) rows of a query result, returning them as a sequence of sequences... An empty sequence is returned when no rows are available."
Keep practicing
Take the free PCPP1 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other PCPP1 practice questions
- Question 1Select the true statements about the connection-oriented and connectionless types of comm…
- Question 2Select the true statements about the sqlite3 module. (Select two answers.)
- Question 5If w is a correctly created main application window, which method would you use to foe bo…
- Question 7Select the true statements about the json.-dumps () function. (Select two answers.)
- Question 9Select the true statements related to PEP 8 naming conventions. (Select two answers.)
- Question 10Select the true statement related to PEP 257.
