title: Place to initialize DB in Flask
body: <p>I'm developing app in Flask and it requires DB, so what I have is I do:</p>
  
  <pre><code>app = Flask(__name__)
  @app.before_request
  def init_db_connection:
    # here I connect to my DB
  
  @app.teardown_request
  def destroy_db(exception):
    # here I destroy database connection
  </code></pre>
  
  <p>On the development server (app.run()) this is not the best place to initialize the database I guess, because also DB will get initialized even it the request comes for the static file. In production I can have a separate web server serving static files, so it shouldn't be a problem.</p>
  
  <p>But still I'm thinking if this is right way to initialize DB or it is better for example to initialize DB in Blueprint which is used in that moment? Just want to know the best practice and how you guys doing this :)</p>
  
  <p>Thanks!</p>