|
List Info
Thread: "ocaml_beginners"::[] pgocaml: how to use it?
|
|
| "ocaml_beginners"::[] pgocaml:
how to use it? |
  South Africa |
2007-08-23 08:05:49 |
|
I am trying out pGOCaml and so far I did not have any success:
$ env | grep PG
PGPORT=5432
PGUSER=js
PGDATABASE=js
PGHOST=localhost
Postgresql is running.
====================
$ make test_pgocaml
ocamlfind ocamlc -g -package unix,extlib,pcre,calendar -I
/usr/local/lib/ocaml/3.09.2/csv -linkpkg csv.cma
-pp "camlp4o /usr/lib/ocaml/3.09.2/unix.cma
/usr/lib/ocaml/3.09.2/str.cma -I +pcre
/usr/lib/ocaml/3.09.2/pcre/pcre.cma -I +extlib
/usr/lib/ocaml/3.09.2/extlib/extLib.cma -I +calendar
/usr/lib/ocaml/3.09.2/calendar/calendar.cma -I
/usr/local/lib/ocaml/3.09.2/csv csv.cma ./pgocaml.cma
./pa_pgsql.cmo" -c test_pgocaml.ml
File "", line 0, characters 0-1:
Uncaught exception: End_of_file
Uncaught exception: End_of_file
Preprocessor error
make: *** [test_pgocaml.cmo] Error 2
=========================
When I try out the example on the home page:
=================
Objective Caml version 3.09.2
Findlib has been successfully loaded. Additional directives:
...
# let () =
let dbh = PGOCaml.connect () in
let insert name salary email =
PGSQL(dbh) "insert into employees (name, salary, email)
values ($name, $salary, $?email)"
in
insert "Ann" 10_000_l None;
insert "Bob" 45_000_l None;
insert "Jim" 20_000_l None;
insert "Mary" 30_000_l (Some " mary%40example.com">mary example.com");
let rows =
PGSQL(dbh) "select id, name, salary, email from employees" in
List.iter (
fun (id, name, salary, email) ->
let email = match email with Some email -> email | None -> "-" in
Printf.printf "%ld %S %ld %Sn" id name salary email
) rows;
PGOCaml.close dbh;;
Characters 92-187:
................"insert into employees (name, salary, email)
values ($name, $salary, $?email)"
Syntax error
#
=======================
And I don't know my way forward from here.
When I try just the 'connect' part, I get the same error as when I try
to compile pg_ocaml:
# let a = PGOCaml.connect ~host:"localhost" ~user:"js" ~database:"js" ();;
Exception: End_of_file.
Regards
Johann
--
Johann Spies Telefoon: 021-808 4036
Informasietegnologie, Universiteit van Stellenbosch
"For God hath not appointed us to wrath, but to obtain
salvation by our Lord Jesus Christ, Who died for us,
that, whether we wake or sleep, we should live
together with him."
I Thessalonians 5:9,10
__._,_.___
.
__,_._,___
|
| Re: "ocaml_beginners"::[]
pgocaml: how to use it? |
  United Kingdom |
2007-08-23 17:02:27 |
|
On Thu, Aug 23, 2007 at 03:05:49PM +0200, Johann Spies wrote:
> Characters 92-187:
> ................"insert into employees (name, salary, email)
> values ($name, $salary, $?email)"
> Syntax error
This isn't going to work unless the camlp4 syntax extension is loaded.
> # let a = PGOCaml.connect ~host:"localhost" ~user:"js" ~database:"js" ();;
> Exception: End_of_file.
This seems to be some problem with the database or protocol itself.
Using 'strace' is probably a good idea, because it basically works for
me on lots of versions of PostgreSQL.
Rich.
--
Richard Jones
Red Hat
__._,_.___
.
__,_._,___
|
| Re: "ocaml_beginners"::[]
pgocaml: how to use it? |
  South Africa |
2007-08-31 04:08:51 |
|
On Thu, Aug 23, 2007 at 11:02:27PM +0100, Richard Jones wrote:
> On Thu, Aug 23, 2007 at 03:05:49PM +0200, Johann Spies wrote:
> > Characters 92-187:
> > ................"insert into employees (name, salary, email)
> > values ($name, $salary, $?email)"
> > Syntax error
>
> This isn't going to work unless the camlp4 syntax extension is loaded.
>
> > # let a = PGOCaml.connect ~host:"localhost" ~user:"js" ~database:"js" ();;
> > Exception: End_of_file.
>
> This seems to be some problem with the database or protocol itself.
> Using 'strace' is probably a good idea, because it basically works for
> me on lots of versions of PostgreSQL.
>
I have 'straced' 'make' now. First I found this when I used
LC_MESSAGE="af_ZA" or "en_ZA":
munmap(0x2b126f1e6000, 4096) = 0
open("/usr/share/locale/en_ZA/LC_MESSAGES/make.mo", O_RDONLY) = -1
ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/make.mo", O_RDONLY) = -1 ENOENT
(No such file or directory)
write(2, "make: ", 6make: ) = 6
write(2, "*** [test_pgocaml.cmo] Error 2", 30*** [test_pgocaml.cmo]
Error 2) = 30
write(2, "n", 1
) = 1
rt_sigprocmask(SIG_BLOCK, [HUP INT QUIT TERM XCPU XFSZ], NULL, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
chdir("/home/js/rugsteun/src/pgocaml-0.8") = 0
close(1) = 0
munmap(0x2b126f1e5000, 4096) = 0
exit_group(2) = ?
Process 14543 detached
Changing it to "en_UK" helped. Strace ended with:
stat("test_pgocaml_lowlevel", {st_mode=S_IFREG|0755, st_size=831239,
...}) = 0
stat("test_pgocaml_lowlevel.cmo", {st_mode=S_IFREG|0644,
st_size=11364, ...}) = 0
stat("test_pgocaml_lowlevel.ml", {st_mode=S_IFREG|0644, st_size=3193,
...}) = 0
stat("test_pgocaml", 0x7fff2b1abf20) = -1 ENOENT (No such file or
directory)
stat("test_pgocaml.cmo", 0x7fff2b1abe30) = -1 ENOENT (No such file or
directory)
stat("test_pgocaml.ml", {st_mode=S_IFREG|0644, st_size=1254, ...}) = 0
fstat(1, {st_mode=S_IFCHR|0700, st_rdev=makedev(4, 3), ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo
...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x2b647fa91000
write(1, "ocamlfind ocamlc -g -package uni"..., 109ocamlfind ocamlc -g
-package unix,extlib,pcre,calendar -I /usr/local/lib/ocaml/3.09.2/csv
-linkpkg csv.cma
) = 109
write(1, "t -pp "camlp4o /usr/lib/ocaml/3"..., 322 -pp "camlp4o
/usr/lib/ocaml/3.09.2/unix.cma /usr/lib/ocaml/3.09.2/str.cma -I +pcre
/usr/lib/ocaml/3.09.2/pcre/pcre.cma -I +extlib
/usr/lib/ocaml/3.09.2/extlib/extLib.cma -I +calendar
/usr/lib/ocaml/3.09.2/calendar/calendar.cma -I
/usr/local/lib/ocaml/3.09.2/csv csv.cma ./pgocaml.cma ./pa_pgsql.cmo"
-c test_pgocaml.ml
) = 322
pipe([3, 4]) = 0
close(4) = 0
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
rt_sigprocmask(SIG_BLOCK, [HUP INT QUIT TERM XCPU XFSZ], NULL, 8) = 0
vfork() = 14577
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
wait4(-1, File "", line 0, characters 0-1:
Uncaught exception: End_of_file
Uncaught exception: End_of_file
Preprocessor error | |