BSD-3-Clause licensed by José Lorenzo Rodríguez , Bryan O'Sullivan , Paul Rouse
Maintained by [email protected]
This version can be pinned in stack with:mysql-haskell-nem-0.1.0.0@sha256:302757858fd59b0a6b35eb447529306708c737b7ca794cafccc4e24e0f71254e,1187

Module documentation for 0.1.0.0

mysql-haskell-nem

Provides a simpler interface for retrieving results when using the mysql-haskell package.

Guide

The Database.MySQL.Base and Database.MySQL.Nem modules provides everything you need to start making queries:

{-# LANGUAGE OverloadedStrings #-}

module Main where

import Database.MySQL.Base
import Database.MySQL.Base.Nem
import Data.Text (unpack)
import qualified System.IO.Streams as Streams

main :: IO () 
main = do
    conn <- connect
        defaultConnectInfo {ciUser = "username", ciPassword = "password", ciDatabase = "dbname"}

	results <- queryResults conn "SELECT email, name FROM users" >>=
	_ <-
		Streams.mapM_
			(\(email, name) -> print $ (Text.unpack email) ++ ":" ++ (name :: String) ) results >>=
		Streams.toList

It’s recommended to use prepared statement to improve query speed:

    ...
    s <- prepareStmt conn "SELECT * FROM some_table where person_age > ?"
    ...
    results <- queryStmtResutls s [MySQLInt32U 18]
    ...