title: flask manage db connection :memory:
body: <p>I have a flask application that needs to store some information from requests. The information is quite short-lived and if the server is restarted I do not need it any more - so I do not really need persistence.</p>
  
  <p>I have read <a href="https://stackoverflow.com/questions/11113903/in-memory-storage-for-flask-application">here</a> that an Sqlite database, which is held in memory can be used for that. What is the best way to manage the database connection? In the flask documentation connections to the database are created on demand, but my database <a href="http://www.sqlite.org/inmemorydb.html" rel="nofollow noreferrer">will be deleted if I close the connection</a>.</p>