Connecting to PostgreSQL

Connect to a PostgreSQL database and run a query.

Add a dependency on ff:postgresql :

dependency ff:postgresql:0.0.0

Import the Pg module from it:

import Pg from ff:postgresql

Create a connection pool with the appropriate connection parameters:

let pool = Pg.newPool(...)

And run your first transaction, e.g.:

pool.transaction {connection =>
    let emails = connection.statement("select email from users")
        .map {row => row.getString("email").grab()}
    Log.debug(emails)
}

Note that .map here runs for each row of the result.