Sophie

Sophie

distrib > PLD > ac > amd64 > media > dist > by-pkgid > 78f6f21909e007faa46b7eb341f259e1 > files > 17

ocaml-postgres-devel-20040120-6.amd64.rpm

if (Array.length Sys.argv <> 3) then (Printf.printf "\
   Usage:  populate conninfo table
   Connect to Postgres with [conninfo] (e.g. \"host=glouglou\"),
   and copy stdin to [table]
"; exit 1);;


let main() =
  let c = new Postgres.connection Sys.argv.(1) in
  let _ = c#exec_expect ("copy "^(Sys.argv.(2))^" from stdin") 
	    [Postgres.Result.Copy_in] in
  c#copy_in_channel stdin;
  c#close

let _ = 
  try main ()
  with 
    | Postgres.Error e -> prerr_endline (Postgres.string_of_error e)
    | e -> prerr_endline (Printexc.to_string e)