0
0
Flaskframework~10 mins

Connection pooling in Flask - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the connection pool class from SQLAlchemy.

Flask
from sqlalchemy.pool import [1]
Drag options to blanks, or click blank then click option'
AConnectionPool
BQueuePool
CPoolManager
DSessionPool
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent class like ConnectionPool.
Confusing session management classes with pool classes.
2fill in blank
medium

Complete the code to create an engine with a connection pool size of 5.

Flask
engine = create_engine('sqlite:///app.db', pool_size=[1])
Drag options to blanks, or click blank then click option'
A5
B0
C1
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Setting pool_size to 0 disables pooling.
Using a number too large or too small for the task.
3fill in blank
hard

Fix the error in the code to correctly dispose the connection pool.

Flask
engine.[1]()
Drag options to blanks, or click blank then click option'
Arelease
Bclose
Cshutdown
Ddispose
Attempts:
3 left
💡 Hint
Common Mistakes
Using close() which only closes one connection.
Using shutdown() which is not a method on engine.
4fill in blank
hard

Fill both blanks to configure the engine with a max overflow of 10 and a pool recycle time of 3600 seconds.

Flask
engine = create_engine('mysql://user:pass@localhost/db', pool_size=5, pool_overflow=[1], pool_recycle=[2])
Drag options to blanks, or click blank then click option'
A10
B3600
C300
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the values between pool_overflow and pool_recycle.
Using zero for pool_overflow disables overflow connections.
5fill in blank
hard

Fill all three blanks to create a scoped session with the engine and bind it properly.

Flask
Session = scoped_session(sessionmaker(bind=[1], autoflush=[2], autocommit=[3]))
Drag options to blanks, or click blank then click option'
Aengine
BTrue
CFalse
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Setting autocommit to True which is deprecated.
Not binding the session to the engine.