from flask import current_app, gg
is a special object that is unique for each request. It is used to store data that might be accessed by multiple functions during the request.
The connection is stored and reused instead of creating a new connection ifget_db
is called a second time in the same requestis another special object that points to the Flask application handling the request.
current_app