
just find myself this solution: 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'" forM_ rows $ \(Only a) -> putStrLn $ Text.unpack a Le 03/12/2018 12:21, Damien Mattei a écrit :
{-# 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 ;-)
-- Damien.Mattei@unice.fr, Damien.Mattei@oca.eu, UNS / OCA / CNRS