views:

271

answers:

3

Hi,

I'm trying to find a lib to access a DB from an Ocaml program. After trying ocaml-sqlite, I'm not satisfied since it's somewhat slow.

I've seen a mysql module but it doesn't seem to be maintained.

thanks.

+3  A: 

Have you checked the Caml Hump? It has links to plenty of database bindings.

Good, mature, bindings that I can recommend are PG'OCaml by Richard Jones and postgresql-ocaml by Markus Mottl. They are both targeted at Postgresql (which is a probably a better choice for you considering you're into Ocaml).

Jon Smark
sure, i've checked this...my concern was that the last releases seem quite old. So i wanted to know what people were actually using.
LB
What do you mean by quite old? In the case of PG'OCaml the latest release is a few months old and there seems to be constant activity in SVN. As for postgresql-ocaml, there are no new release because there's no need to upgrade what runs fine... :-)
Jon Smark
ok, my bad, I didn't go to the PG'Ocaml new web site. and for postgresql-ocaml, I didn't want to invest time on something I cannot use. thx.
LB
I too use PG'OCaml and find it quite excellent.
Michael E
I'll give it a try. By modifying my schemas, the parsing/insertion in sqlite is much faster, but postgresql seems attractive.
LB
+2  A: 

I'm quite surprised that you find the ocaml-sqlite bindings slow. sqlite is fast on its own, and I believe the sqlite bindings are very well written. You should make sure you're using the up-to-date binding from Markus Mottl's page

zrr
maybe i'm a bit demanding, I'm parsing a 100 Mo text file and building a the database. I've many inserts to do, so I had to be more clever concerning the calls to exec. I'm using the last version. I don't know what is the performance penalty induced by the IO to the data base. file
LB
Only 100Mo?! I parse that in my sleep... literally!
nlucaroni
i don't know what to answer :-). You're parsing it in your sleep because it takes so long that you fall asleep ?
LB
heh, (that I'd let it run overnight), but it looks like you know all your options. let us know your final decision and how it worked out.
nlucaroni
Consider using prepared statements to reduce overhead of multiple INSERT's.
ygrek
+1  A: 

ocaml-mysql works without problems here - mysql api for connect/query/fetch doesn't change that much :) It lacks prepared statements though, had to implement mysql_stmt_* wrappers myself.

ygrek