1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
OCamlODBC : Accessing databases from OCaml via ODBC
*** What is OCamlODBC ***
OCamlODBC is a library allowing to acces databases via an Open
DataBase Connectivity (ODBC) driver from OCaml programs.
*** What you need ***
- OCaml >= 3.0x installed (3.01 or 3.02 for the Biniki example)
- ODBC driver installed (headers and libs), for example iODBC for
MySQL or the PostgreSQL-ODBC package for PostgreSQL
- LablGtk >= 2.6 installed for the Biniki example
- make ;-)
*** How to compile ***
- ./configure <options>
(./configure --help to see options, or myconf for an example)
- make <db>
where <db> can be one or several of the following :
- mysql
- postgres
- db2
- openingres
- unixodbc
- oraclecfo
depending on which ODBC drivers are available on your system.
You may need to make some changes to compile successfully:
- in master.Makefile the -ldopt should be replaced by -Xlinker
You may have a look at the Makefile.nt, configure.nt and Exemples/Makefile.nt files
to compile under Windows with MinGW, thanks to David Allsopp which gave these
files with this comment:
>> I have produced a Makefile.nt with accompanying configure.nt scripts which
>> attempt to replicate the behaviour of Makefile. To build and install the
>> entire system under Windows, from a Cygwin bash prompt, execute
>> make -f Makefile.nt findlib_install
>> or
>> make -f Makefile.nt direct_install
>> depending on which installation method you wish to use. This builds the
>> bytecode library ocamlodbc.cma and native code library ocamlodbc.cmxa linked
>> with the Windows ODBC Interface.
>> Exemples/Makefile.nt compiles the four example programs using the library.
- make install
will install the compiled libraries in
<ocamldir>/lib/ocaml/ocamlodbc/[mysql|postgres|db2|openingres|unixodbc|oraclecfo]
*** How to use ****
The directory 'Exemples' contains some examples.
- cd Exemples
- make BASE=XX PROG to create monitor.x
where XX can be MYSQL, POSTGRES, DB2, OPENINGRES or unixODBC, ORACLECFO
- monitor.x <a database> <a user name> [<a password>]' to connect to a
database ; you can type in commands on the prompt (select * from ...)
The directory Biniki contains a simple application to execute SQL
queries and display the results in a window. It needs LablGTK 1.2.
- cd Biniki
- make fr or make en to create a link to the messages file you want
- make <db> to create biniki and biniki.opt
where <db> can be mysql, postgres, db2, openingres or unixodbc
- biniki[.opt] <base> [user [password]]
to connect to a database you're allowed to, and enjoy !
*** Author ***
Maxence Guesdon <maxence.guesdon@inria.fr>. Let me know if you use
OCamlODBC with another database system, so i can add it to the
distrib.
|