Skip to content
Parse database urls into the concrete configuration types required by Persistent
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Database/Persist
test
.gitignore
.travis.yml
LICENSE
README.md
Setup.hs
persistent-database-url.cabal
stack.yaml

README.md

persistent-database-url

Converts the parameters parsed from a database url to the concrete configuration types required by persistent.

Currently, only persistent-postgresql's PostgresConf is provided.

Installation

cabal install persistent-database-url

Example Usage

Adjusting the Yesod scaffold to run on Heroku:

config/settings.yml

database-url: "_env:DATABASE_URL:postgres://user:pass@localhost:5432/dbname"
database-pool-size: "_env:DB_POOL:5"

Settings.hs:

import Database.Persist.URL (fromDatabaseUrl)

instance FromJSON AppSettings where
    parseJSON = withObject "AppSettings" $ \o -> do
        appDatabaseConf <- fromDatabaseUrl
                             <$> o .: "database-pool-size"
                             <*> o .: "database-url"
        -- ...

        return AppSettings {..}

How to run tests

stack test
You can’t perform that action at this time.