title: Vapor connect to SQLite Database
body: <p>I'm trying to setup a Vapor 3 project with SQLite.<br>
  In the <code>configure.swift</code> file, I have the following setup related to sqlite:</p>
  
  <pre><code>try services.register(FluentSQLiteProvider())
  
  ...
  
  // Get the root directory of the project
  // I have verified that the file is present at this path
  let path = DirectoryConfig.detect().workDir + "db_name.db"
  let sqlite: SQLiteDatabase
  do {
      sqlite = try SQLiteDatabase(storage: .file(path: path))
      print("connected") // called
  } catch {
      print(error) // not called
      return
  }
  
  var databases = DatabasesConfig()
  databases.add(database: sqlite, as: .sqlite)
  services.register(databases)
  </code></pre>
  
  <p>In the database, I have a table called <code>posts</code>, that I want to query and return all entries from:</p>
  
  <p><a href="https://i.stack.imgur.com/KVIuB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KVIuB.png" alt="database table"></a></p>
  
  <p>This is the <code>Post</code> implementation inside <em>/Sources/App/Models/</em>:</p>
  
  <pre><code>final class Post: Content {
      var id: Int?
      var title: String
      var body: String
  
      init(id: Int? = nil, title: String, body: String) {
          self.id = id
          self.title = title
          self.body = body
      }
  }
  extension Post: SQLiteModel, Migration, Parameter { }
  </code></pre>
  
  <p>I have also added the migration in <code>configure.swift</code>:</p>
  
  <pre><code>var migrations = MigrationConfig()
  migrations.add(model: Post.self, database: .sqlite)
  services.register(migrations)
  </code></pre>
  
  <p>In <code>routes.swift</code>, I define the <code>posts</code> route as follows:</p>
  
  <pre><code>router.get("posts") { req in
      return Post.query(on: req).all()
  }
  </code></pre>
  
  <p>Now, when calling <code>localhost:8080/posts</code>, I get:</p>
  
  <pre><code>[]
  </code></pre>
  
  <p>Have I not properly connected the database?<br>
  Have I missed something?</p>