Created
October 24, 2014 13:32
-
-
Save edvardm/598fc211be1b392a754a to your computer and use it in GitHub Desktop.
test postgres adapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Toy program to see how to work with values that are not guaranteed to be present with
Database.PostgreSQL.Simple