title: explicitly close db connection in slick
body: <p>Here is code I am trying to optimise:</p>
  
  <pre><code>object UserRepo
  {
    val users = TableQuery[Users]
  
    val dbName = "db"
  
    lazy val queryAllUsers = for (user &lt;- users) yield user
  
    type UserRow =  (Int, String, String, String)
  
    def getAll() : Future[ Seq[UserRow] ] =
    {
      val db = Database.forConfig( dbName )
  
      val f: Future[Seq[UserRow]] = db.run( queryAllUsers.result )
  
      f.onComplete {
        case Success(_) =&gt; { db.close() }
        case Failure(_) =&gt; { db.close() }
      }
  
      f
    }
  
  }
  </code></pre>
  
  <p>I going to have number of query to the DB I am trying to get rid of string where I am creating DB connection. Is there any execution context I can use to close connection explicitly ?? so code will look more concise ? </p>
  
  <p>Is there option to get used db connection within Future.onComplete scope??</p>
  
  <p>Thanks</p>