|
From: <bri...@cs...> - 2008-01-28 11:43:49
|
On Jan 27, 2008, at 01:35 , Immanuel Normann wrote:
> I posted this two weeks ago also to haskell-cafe, but the answers =20
> didn't help that much. So I try here again:
>
> with the release update haskelldb-0.9 -> haskelldb-0.10 several =20
> things have changed. Unfortunately the API documentation does not =20
> give enough information in generall. Is there any additional =20
> uptodate documentation around?
> In particular the fundamental function "connect" hast a new signature:
> connect :: (forall m a . MonadIO m =3D> [(String, String)] -> =20
> (Database -> m a) -> m a)
> I don't know what pairs of strings this function needs. The API =20
> description is to unspecific:
>
> The connect function takes some driver specific name, value pairs =20
> use to setup the database connection, and a database action to run.
>
> What are the specific name value pairs needed (for a connection to =20
> a mysql db )?
> I got the following hint:
> Your best bet is to download the appropriate drivers - either =20
> haskelld-hdbc-mysql or haskelldb-hsql-mysql. If you get the =20
> haskelldb sources via darcs, you can also look in the test =20
> directory to see how the connections are established.
>
> In my specific case, I am using PostgreSQL and by login function =20
> looks like this:
>
> -- ^ Returns a function which can log into the database and perform =20=
> operations.
> login :: MonadIO m =3D> String -> Int -> String -> String -> String -=20=
> > (Database -> m a) -> m a
> login server port user password dbname =3D postgresqlConnect =20
> [("host", server),
> ("port", show port),
> ("user", user),
> ("password", password),
> ("dbname", dbname)]
>
> I don't understand how to map this to my problem. What in fact do I =20=
> have to install?
> For MySQL there seem to be the following dependencies when I try to =20=
> setup haskelldb-hsql-mysql-0.10 froma hackage:
> - haskelldb-hsql-0.10
> - hsql-1.7
> - hsql-mysql-1.7
> I haven't manage to install them with ghc-6.8.2 yet. Nevertheless I =20=
> wouldn't know how to use this "cpnnect" function. Moreover, in =20
> contrast to the haddock type description I observe with ghci and :t =20=
> connect the following type:
> connect :: (MonadIO m) =3D>
> DriverInterface
> -> [(String, String)]
> -> (Database.HaskellDB.Database.Database -> m a)
> -> m a
> I don't what to take for "DriverInterface"? The API docu says:
> "Default dummy driver, real drivers should overload this"
> How should this be done concretely for MySQL?
>
> Some more detailed docu would be helpful.
Hi Immanuel,
Sorry about the poor state of the HaskellDB documentation.
Short story:
1. Install the darcs versions of these packages:
hsql
hsql-mysql
haskelldb
haskelldb-hsql
haskelldb-hsql-mysql
2. Import Database.HaskellDB.HSQL.MySQL
3. You need these options:
options =3D
[("server","<server host name>"),
("db","<database name>"),
("uid","<username>"),
("pwd","<password>")]
4. Call:
connect driver options <your function>
You currently need the darcs versions since HSQL 1.7 does not compile =20=
under GHC 6.8.2.
There really ought to be an up-to-date HaskellDB tutorial. Perhaps it =20=
should live on the Haskell Wiki so that everyone can contribute.
/Bj=F6rn
|