[Haskell-cafe] Re: simple hsql question
sacha at myxomop.com
Mon Aug 17 16:14:48 EDT 2009
Ok, let me ask it in another way. Is there a good way to access
databases, mysql in particular, from haskell program?
>>>>> On Sun, 16 Aug 2009 18:54:32 +0400
>>>>> "AK" == Alexander Kotelnikov <sacha at myxomop.com> wrote:
AK> I wanted to see what access to databases HSQL provides and I stumbled in
AK> the very beginning. Assume I have a table map1 with attributes "i" and "s"
AK> interger and varchar() respectively. The following code fails (with
AK> segfault) for me. And I see no other way to tell compiler that I am
AK> expecting an interger to be found as 'i' in a fetched row.
AK> import Database.HSQL
AK> import Database.HSQL.MySQL
AK> main :: IO ()
AK> main = do
AK> c <- connect "localhost" "tx_test" "sacha" ""
AK> s <- query c "SELECT i FROM map1"
AK> print $ getFieldsTypes s
AK> i <- (getFieldValue s "i")::IO Int
AK> print i
AK> disconnect c
AK> Alexander Kotelnikov
AK> Saint-Petersburg, Russia
More information about the Haskell-Cafe