Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. database access,extracting result... (Damien Mattei)
----------------------------------------------------------------------
Message: 1
Date: Mon, 3 Dec 2018 12:21:54 +0100
From: Damien Mattei <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] database access,extracting result...
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
{-# LANGUAGE OverloadedStrings #-}
import Database.MySQL.Simple
import Control.Monad
import Data.Text as Text
import Data.Int
main :: IO ()
main = do
conn <- connect defaultConnectInfo
{ connectHost = "moita",
connectUser = "mattei",
connectPassword = "******",
connectDatabase = "sidonie" }
rows <- query_ conn "select `N° BD` from sidonie.Coordonnées where Nom
= 'A 20'"
--putStrLn $ show rows
forM_ rows $ \(fname, lname) ->
putStrLn $ fname ++ " " ++ Text.unpack lname ++ " "
here is the error:
*Main> :load Toto
[1 of 1] Compiling Main ( Toto.hs, interpreted )
Ok, one module loaded.
*Main> main
*** Exception: ConversionFailed {errSQLType = "1 values:
[(VarString,Just \"-04.3982\")]", errHaskellType = "2 slots in target
type", errFieldName = "[\"N\\194\\176 BD\"]", errMessage = "mismatch
between number of columns to convert and number in target type"}
-04.3982 is the values i want to put in a variable,it's the N° BD
(Durchmusterung Number)
???
any help greatly appeciated ;-)
--
[email protected], [email protected], UNS / OCA / CNRS
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 126, Issue 1
*****************************************