mysql-haskell-nem: Adds a interface like mysql-simple to mysql-haskell.

[ bsd3, database, library ] [ Propose Tags ] [ Report a vulnerability ]

Please see README.md


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Dependencies base (>=4.7 && <5), bytestring, io-streams, mysql-haskell, scientific, text, time [details]
License BSD-3-Clause
Copyright 2016 José Lorenzo Rodríguez
Author José Lorenzo Rodríguez , Bryan O'Sullivan , Paul Rouse
Maintainer jose.zap@gmail.com
Category Database
Home page https://github.com/lorenzo/mysql-haskell-nem#readme
Source repo head: git clone https://github.com/lorenzo/mysql-haskell-nem
Uploaded by lorenzo at 2016-12-18T16:03:30Z
Distributions LTSHaskell:0.1.0.0, Stackage:0.1.0.0
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1356 total (8 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-12-18 [all 1 reports]

Readme for mysql-haskell-nem-0.1.0.0

[back to package description]

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]
    ...