Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lorenzo/mysql-haskell-nem
A simpler query interface for mysql-haskell
https://github.com/lorenzo/mysql-haskell-nem
haskell mysql mysql-haskell
Last synced: 12 days ago
JSON representation
A simpler query interface for mysql-haskell
- Host: GitHub
- URL: https://github.com/lorenzo/mysql-haskell-nem
- Owner: lorenzo
- License: other
- Created: 2016-12-18T16:06:18.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-24T09:54:13.000Z (about 7 years ago)
- Last Synced: 2024-10-11T06:33:25.269Z (29 days ago)
- Topics: haskell, mysql, mysql-haskell
- Language: Haskell
- Homepage: https://hackage.haskell.org/package/mysql-haskell-nem
- Size: 7.81 KB
- Stars: 3
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
mysql-haskell-nem
=================Provides a simpler interface for retrieving results when using the [mysql-haskell](http://hackage.haskell.org/package/mysql-haskell) package.
Guide
-----The `Database.MySQL.Base` and `Database.MySQL.Nem` modules provides everything you need to start making queries:
```haskell
{-# LANGUAGE OverloadedStrings #-}module Main where
import Database.MySQL.Base
import Database.MySQL.Base.Nem
import Data.Text (unpack)
import qualified System.IO.Streams as Streamsmain :: 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:
```haskell
...
s <- prepareStmt conn "SELECT * FROM some_table where person_age > ?"
...
results <- queryStmtResutls s [MySQLInt32U 18]
...
```