Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Open database before request

Hi,

I am planning to integrate a database in my dash app. I have been reading the last few days on which approach I should take. At the moment I am planning on using peewee (an ORM), any better suggestions are more than welcome. In the documentation, they use the ‘before_request’ decorator, to open the database and a ‘tear_down_request’ to close the database. Because I use a Dash interval component these events are triggered allot.

Example code for the 'before_request:

@app.server.before_request
def _db_connect():
print(‘test’)

Outcome:
127.0.0.1 - - [13/Feb/2019 19:57:35] “POST /_dash-update-component HTTP/1.1” 200 -
127.0.0.1 - - [13/Feb/2019 19:57:35] “POST /_dash-update-component HTTP/1.1” 200 -
test
test

  1. Will all these requests for opening/closing the database form a problem?
  2. Are there any ways of integrating a database within Dash?

Any advice is more than welcome!