How to request database connections in Flask?

How to request database connections in Flask?

To establish database connection, we need to use the function - connect_db. We can use “request” variable, which is the request object associated with the current request.