Skip to content

Instantly share code, notes, and snippets.

@edvardm
Created October 24, 2014 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edvardm/598fc211be1b392a754a to your computer and use it in GitHub Desktop.
Save edvardm/598fc211be1b392a754a to your computer and use it in GitHub Desktop.
test postgres adapter
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.Text as Text
import Database.PostgreSQL.Simple
import Control.Monad
import Control.Applicative
import Data.Maybe
queryStuff :: IO ()
queryStuff = do
conn <- connectPostgreSQL "dbname='test_db'"
xs <- query_ conn "select email,encrypted_password from users"
forM_ xs $ \(email,encrypted_password :: Maybe String) ->
putStrLn $ email ++ fromMaybe "n/a" encrypted_password
main = do
queryStuff
@edvardm
Copy link
Author

edvardm commented Oct 24, 2014

Toy program to see how to work with values that are not guaranteed to be present with
Database.PostgreSQL.Simple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment