title: Open and close db with Swift + FMDB
body: <p>What is the recommended way to open and close a sqlite db connection with Swift + FMDB?</p>
  
  <p>I'm following this <a href="http://www.techotopia.com/index.php/An_Example_SQLite_based_iOS_8_Application_using_Swift_and_FMDB#Creating_the_Database_and_Table" rel="nofollow">tutorial</a> which suggests that you should open and close a database like:</p>
  
  <pre><code>let db = FMDatabase(path: databasePath as String)
  if db.open() {
      //do stuff
      db.close()
  </code></pre>
  
  <p>Closing the db outside of a finally block would be a red flag in other languages I've used.  I know swift/iOS exception handling is <em>different</em> than most languages and dev environments.  But I'm still concerned that this is still a really unsafe way to close the database connection.</p>
  
  <p>Is this method of closing a db actually safe &amp; recommended?<br>
  Should I be using something like <a href="https://github.com/williamFalcon/SwiftTryCatch" rel="nofollow">SwiftTryCatchFinally</a> instead?</p>
  
  <pre><code>let db = FMDatabase(path: databasePath as String)
  SwiftTryCatch.try({
      connection = db.open()
      if connection {
          //do stuff
      }
  }, catch: {
  
  }, finally: {
      if connection {
          db.close()
      }
  })
  </code></pre>
  
  <p><em>iOS exception handling is so foreign to me :P</em></p>