1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
(* неработающий вариант *)
let print_customer (id, name) = Printf.printf "%ld - %s\n" id name
let get_customers dbh = PGSQL(dbh) "SELECT id, name from customer LIMIT 10"
let _ =
let dbh = PGOCaml.connect ~host:"somehost" ~user:"someuser" ~password:"somepass" ~database:"somedb" () in
List.iter print_customer (get_customers dbh)
(* работающий вариант *)
let print_customer (id, name) = Printf.printf "%ld - %s\n" id name
let get_customers dbh = PGSQL(dbh) "user=someuser" "database=somedb" "host=somehost" "password=somepass" "SELECT id, name from customer LIMIT 10"
let _ =
let dbh = let dbh = PGOCaml.connect ~host:"somehost" ~user:"someuser" ~password:"somepass" ~database:"somedb" () in
List.iter print_customer (get_customers dbh)