On 21 June 2011 16:47, David Virebayre <dav.vire+hask...@gmail.com> wrote: > For example, how to write a function that returns the columns of a > table using show columns ? > > type Champ = (String,String,String,String,String,String) > getColumns :: Connection -> String -> IO [Champ] > getColumns conn table = do > query_ conn (fromString $ "show columns from " ++ table) > > if you try query conn "show columns from " ( Only table), the query built is > show columns from 'xxxxx' > which fails.
For this you could have newtype Entity = Entity String and implement the Param class for this type which will output the string in double quotes, and then you can write: query conn "SHOW COLUMNS FROM ?" (Only "mytable") (With OverloadedStrings enabled.) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe