]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/mathql_interpreter/dbconn.ml
the db connection parameters are now parametrized istead of hard-coded
[helm.git] / helm / ocaml / mathql_interpreter / dbconn.ml
index 17264f5cb17408e0526ec5f73e619965d04f2d16..b38eabe8712f71dcae52b59177ea7f1bc24c01e1 100644 (file)
  *)
 open MathQL;;
 
-exception DBInvalidURI of string
-exception DBConnectionFailed of string
-exception DBInvalidConnection of string
-
-
-
-(*
- * paramentri della connessione
- *
- * TODO: bisogna scegliere se questi parametri vengono
- * passati come argomento
- *)
-(*let connection_param = "dbname=helm";;*)
-let connection_param = "host=mowgli.cs.unibo.it dbname=helm user=helm";;
+exception InvalidURI of string
+exception ConnectionFailed of string
+exception InvalidConnection
 
 (*
  * connessione al db
  *)
-let conn = ref None;;
+let conn = ref None
 
 (*
  * controllo sulla connessione
  *)
 let pgc () =
    match !conn with
-      None -> raise (DBInvalidConnection connection_param)
+      None   -> raise InvalidConnection
     | Some c -> c
 ;;
 
@@ -68,12 +57,11 @@ let pgc () =
  * TODO
  * passare i parametri della connessione come argomento di init
  *)
-let init () =
+let init connection_param =
    try (
     conn := Some (new Postgres.connection connection_param);
-    prerr_endline "connected."
    ) with
-    _ -> raise (DBConnectionFailed ("init: " ^ connection_param))
+    _ -> raise (ConnectionFailed ("init: " ^ connection_param))
 ;;
 
 (*