Skip to content

Instantly share code, notes, and snippets.

@joastbg
Last active December 26, 2015 21:09
Show Gist options
  • Select an option

  • Save joastbg/7213828 to your computer and use it in GitHub Desktop.

Select an option

Save joastbg/7213828 to your computer and use it in GitHub Desktop.
Haskell - HDBC and MySQL
import Control.Monad
import System.IO
import Database.HDBC
import Database.HDBC.MySQL
import Data.Char
import qualified Data.Map as Map
main = do conn <- connectMySQL defaultMySQLConnectInfo {
mysqlUser = "testing",
mysqlPassword = "testing1234",
mysqlDatabase = "test"
}
rows <- quickQuery' conn "SELECT * from persons" []
forM_ rows $ \row -> putStrLn $ show row
sth <- prepare conn "SELECT * from persons"
execute sth []
cols <- getColumnNames sth
forM_ cols $ \col -> putStrLn $ show col
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment