0

I'm new to Haskell. I've read most of LYAH and RWH and have also done some small programms. No I would like to use Haskell with an Oracle DB. I would like to use HaskellDB with HDBC.ODBC.

I was able to connect to the DB via HDBC and run a query. But I don't know how to connect via HaskellDB and ODBC. I can't find an example.

user3535953
  • 143
  • 6

1 Answers1

0

You connect with the odbcConnect function in the [haskelldb-hdbc-opbc][1] package.

Here is at its source:

odbcConnect :: MonadIO m => SqlGenerator -> [(String,String)] -> (Database -> m a) -> m a
odbcConnect gen opts = hdbcConnect gen (connectODBC conninfo)
    -- strangely enough, mysql+unixodbc want a semicolon terminating connstring
    where conninfo = foldr (\(k,v) z -> k ++ "=" ++ v ++ ";" ++ z) [] opts

There we can see that it calls out to connectODBC which you know how to use already. The difference is that here we take a list of pairs of (OptionName,OptionValue) rather than a simple string, and those options get rendered as key=value; pairs in the connection string passed to connectODBC.

sclv
  • 38,665
  • 7
  • 99
  • 204