QuizzesSQLAlchemy Setup — Engine, Sessions & Models — Concept Check
intermediate
fastapi

SQLAlchemy Setup — Engine, Sessions & Models — Concept Check

Questions on SQLAlchemy Setup — Engine, Sessions & Models. One engine per app (with a connection pool), one session per request (via the get_db yield dependency), ORM models declaring tables in Python — the wiring every FastAPI + Postgres service shares.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on SQLAlchemy Setup — Engine, Sessions & Models — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A FastAPI application is experiencing stale data issues when handling multiple requests. What is a likely cause?

    • AUsing multiple engines per application
    • BSharing a session across requests
    • CNot using pool_pre_ping
    • DIncorrect pool size configuration
  2. 2.A developer notices high latency during database operations after a PostgreSQL restart. What configuration might help?

    • AEnable pool_pre_ping
    • BIncrease pool_size
    • CUse multiple engines
    • DDecrease max_overflow
  3. 3.Which of the following is true about SQLAlchemy sessions in a FastAPI application?

    • AMultiple sessions per request improve performance
    • BOne session per request is recommended
    • CSessions are long-lived and reused
    • DSessions should be shared across threads
  4. 4.A service using SQLAlchemy slows down under high traffic. What should be checked first?

    • APool size and max overflow settings
    • BSession lifetime
    • CNumber of engines
    • DNumber of sessionmakers
  5. 5.What is the purpose of the sessionmaker in SQLAlchemy?

    • ATo configure database engines
    • BTo map classes to database tables
    • CTo manage connection pooling
    • DTo create new sessions for requests
  6. 6.A developer mistakenly believes that increasing the number of engines improves performance. Why is this incorrect?

    • AMultiple engines increase connection overhead
    • BOne engine per application is sufficient
    • CEngines do not affect session creation
    • DEngines are unrelated to performance
  7. 7.What could be a consequence of not closing a session after a request?

    • AConnection leaks and pool exhaustion
    • BAutomatic session reuse
    • CImproved performance
    • DIncreased database security