Courseiva

PCPP2 · domain

Database Access

Practise Python Institute Certified Professional in Python Programming 2 (PCPP2) (PCPP2) Database Access practice questions — original exam-style scenarios with answer choices, explanations, and analysis of common mistakes.

34 questions10 easy14 medium10 hard

Focused practice

Practice Database Access questions

Scored sessions drawing only from this domain — pick a length below.

Start 20-question practice test →

What this domain covers

What to know about Database Access

Database Access questions test whether you can apply the concept in context, not just recognise a definition.

How the topic appears in realistic exam-style scenarios.

Which detail in the question changes the correct answer.

How to eliminate plausible but wrong options.

How to connect the question back to the wider exam objective.

Watch out for

Common Database Access exam traps

  • Answering from memory before reading the full scenario.
  • Missing a constraint such as cost, availability, security, scope or command context.
  • Choosing a broad answer when the question asks for the most specific fix.
  • Ignoring why the wrong options are tempting.

Question index

All Database Access questions (34)

Click any question to see the full explanation, or start a practice session above.

1

You are using sqlite3 in Python and need to ensure that data integrity is maintained when performing multiple related INSERT operations. Which method should you call on the connection object to commit your changes?

Easy
2

Which Python library is the standard built-in interface for SQLite databases?

Easy
3

How do you retrieve the number of documents matched by a PyMongo 'find' operation without fetching all documents into memory?

Medium
4

Which of the following best describes the benefit of using parameterized queries in sqlite3?

Easy
5

In sqlite3, how do you handle a database error such as a constraint violation?

Easy
6

Which TWO of these are valid parameters for the MongoClient constructor?

Medium
7

What is the purpose of the 'upsert=True' option in MongoDB update operations?

Medium
8

You are implementing a custom type in SQLAlchemy. Which method must be overridden to convert data from the database type back to a Python object?

Hard
9

Which object in SQLAlchemy is responsible for maintaining a collection of loaded objects and managing their lifecycle?

Medium
10

You are using SQLAlchemy with an asynchronous driver (asyncio). Which object must be used to perform database operations asynchronously?

Hard
11

Which THREE of these are valid relationship loading strategies in SQLAlchemy?

Hard
12

In SQLAlchemy, what does the 'metadata.create_all(engine)' command do?

Medium
13

When using the sqlite3 module, what is the primary purpose of using a context manager (the 'with' statement) on a connection object?

Easy
14

Which TWO are common pitfalls when working with SQLite databases in a multi-threaded environment?

Easy
15

Which THREE are valid cascade options in SQLAlchemy?

Hard
16

Which THREE operations are supported by the PyMongo 'bulk_write' method?

Medium
17

Which THREE methods are part of the PEP 249 Python DB-API 2.0 interface?

Easy
18

Which THREE features are provided by SQLAlchemy's Unit of Work pattern?

Hard
19

In SQLAlchemy, how do you prevent an object from being saved to the database during a session.commit()?

Hard
20

Which THREE are characteristics of BSON (Binary JSON) as used by MongoDB?

Medium
21

Which TWO are common methods to handle BSON Date objects in PyMongo?

Easy
22

Which PyMongo method should be used to update a single document if you want to modify specific fields without replacing the entire document?

Medium
23

In a PyMongo application, what happens when you use 'insert_many' with 'ordered=False'?

Hard
24

Which TWO of the following are valid ways to execute a raw SQL query in SQLAlchemy?

Medium
25

When connecting to a MongoDB instance using PyMongo, what is the role of the 'MongoClient' object?

Medium
26

When configuring a connection pool in SQLAlchemy, what does the 'pool_size' parameter define?

Hard
27

In SQLAlchemy, what is the difference between 'lazy='select'' and 'lazy='joined'' loading strategies?

Medium
28

You are developing an application using SQLAlchemy and need to retrieve a single object by its primary key. Which method is preferred for this operation?

Medium
29

When using the MongoDB aggregation framework in PyMongo, which stage should be used to filter documents based on a condition?

Hard
30

When performing bulk inserts in PyMongo, which method is the most efficient?

Medium
31

You are using SQLAlchemy's relationship() function. What does 'back_populates' achieve?

Hard
32

Which command-line tool is typically used to inspect the contents of a SQLite database file?

Easy
33

When using SQLAlchemy Declarative Base, how do you define a table name that differs from the class name?

Medium
34

In SQL, which clause is used to filter results based on a condition after grouping?

Easy

Frequently asked questions

What does the Database Access domain cover on the PCPP2 exam?
Database Access questions test whether you can apply the concept in context, not just recognise a definition.
How many questions are in this domain?
This page lists all 34 Database Access questions in the PCPP2 question bank. The actual exam draws from this domain proportionally to its weighting in the official exam blueprint.
What is the best way to practise this domain?
Start with a short focused session (10 questions) to identify gaps, then work through explanations. Repeat with a longer session once the weak areas feel solid.
Can I practise only Database Access questions?
Yes — the session launcher on this page filters questions to this domain only. Choose any session length for inline explanations and scoring.
python-pcpp2 PYTHON-PCPP2 database access Practice Questions