[Haskell-cafe] simple hsql question

Alexander Kotelnikov sacha at myxomop.com
Sun Aug 16 10:54:32 EDT 2009


I wanted to see what access to databases HSQL provides and I stumbled in
the very beginning. Assume I have a table map1 with attributes "i" and "s"
interger and varchar() respectively. The following code fails (with
segfault) for me. And I see no other way to tell compiler that I am
expecting an interger to be found as 'i' in a fetched row.

import Database.HSQL
import Database.HSQL.MySQL

main :: IO ()
main = do
    c <- connect "localhost" "tx_test" "sacha" ""
    s <- query c "SELECT i FROM map1"
    print $ getFieldsTypes s
    i <- (getFieldValue s "i")::IO Int
    print i
    disconnect c

Alexander Kotelnikov
Saint-Petersburg, Russia

More information about the Haskell-Cafe mailing list