-mQIConn.cmi: mQIMap.cmi
+mQIConn.cmi: mQIMap.cmi mQIPostgres.cmi
mQIProperty.cmi: mQIConn.cmi
mQueryInterpreter.cmi: mQIConn.cmi
mQueryTParser.cmo: mQueryTParser.cmi
mQueryUtil.cmx: mQueryTLexer.cmx mQueryTParser.cmx mQueryUtil.cmi
mQIUtil.cmo: mQIUtil.cmi
mQIUtil.cmx: mQIUtil.cmi
+mQIDataBase.cmo: mQIDataBase.cmi
+mQIDataBase.cmx: mQIDataBase.cmi
mQIPostgres.cmo: mQIPostgres.cmi
mQIPostgres.cmx: mQIPostgres.cmi
+mQIMySql.cmo: mQIMySql.cmi
+mQIMySql.cmx: mQIMySql.cmi
mQIMap.cmo: mQueryUtil.cmi mQIMap.cmi
mQIMap.cmx: mQueryUtil.cmx mQIMap.cmi
-mQIConn.cmo: mQIMap.cmi mQIPostgres.cmi mQIConn.cmi
-mQIConn.cmx: mQIMap.cmx mQIPostgres.cmx mQIConn.cmi
-mQIProperty.cmo: mQIConn.cmi mQIMap.cmi mQIPostgres.cmi mQIUtil.cmi \
+mQIConn.cmo: mQIDataBase.cmi mQIMap.cmi mQIConn.cmi
+mQIConn.cmx: mQIDataBase.cmx mQIMap.cmx mQIConn.cmi
+mQIProperty.cmo: mQIConn.cmi mQIDataBase.cmi mQIMap.cmi mQIUtil.cmi \
mQIProperty.cmi
-mQIProperty.cmx: mQIConn.cmx mQIMap.cmx mQIPostgres.cmx mQIUtil.cmx \
+mQIProperty.cmx: mQIConn.cmx mQIDataBase.cmx mQIMap.cmx mQIUtil.cmx \
mQIProperty.cmi
mQueryInterpreter.cmo: mQIConn.cmi mQIProperty.cmi mQIUtil.cmi mQueryUtil.cmi \
mQueryInterpreter.cmi
PACKAGE = mathql_interpreter
-REQUIRES = helm-urimanager helm-mathql postgres
+REQUIRES = helm-urimanager helm-mathql mysql postgres
#natile-galax
PREDICATES =
INTERFACE_FILES = mQueryUtil.mli mQIUtil.mli \
- mQIPostgres.mli mQIMap.mli mQIConn.mli \
+ mQIDataBase.mli mQIPostgres.mli mQIMySql.mli mQIMap.mli mQIConn.mli \
mQIProperty.mli mQueryInterpreter.mli
IMPLEMENTATION_FILES = mQueryTParser.ml mQueryTLexer.ml \
type handle = {
log : string -> unit; (* logging function *)
set : flag list; (* options *)
- pgc : Postgres.connection option; (* PG connection *)
+ pgc : MQIDataBase.connection option; (* PG connection *)
pgm : MQIMap.pg_map; (* PG conversion function *)
pga : MQIMap.pg_alias (* PG table aliases *)
}
if List.mem Galax flags then
None
else
- MQIPostgres.init
+ MQIDataBase.init
(Helm_registry.get "mathql_interpreter.postgresql_connection_string");
pgm = m; pga = a
}
let close handle =
- if set handle Galax then () else MQIPostgres.close handle.pgc
+ if set handle Galax then () else MQIDataBase.close handle.pgc
let connected handle =
if set handle Galax then false else (pgc handle) <> None
val log : handle -> string -> unit
val set : handle -> flag -> bool
-val pgc : handle -> Postgres.connection option
+val pgc : handle -> MQIDataBase.connection option
val flags : handle -> flag list
val tables : handle -> MathQL.path -> MQIMap.pg_tables
val field : handle -> MathQL.path -> string -> string
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+type connection
+
+val init : string -> connection option
+
+val close : connection option -> unit
+
+val exec : connection option -> string -> string list list
+
+val quote : string -> string
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+type connection = Mysql.dbd
+
+let init connection_string =
+ try
+ Some
+ (Mysql.quick_connect
+ ~host:"mowgli.cs.unibo.it" ~database:"mowgli" ~user:"helm" ())
+ with _ -> raise (Failure ("MQIPostgres.init: " ^ connection_string))
+
+let close = function
+ | None -> ()
+ | Some c -> Mysql.disconnect c
+
+let exec c q = match c with
+ | None -> []
+ | Some c ->
+ Mysql.map
+ ~f:(function a ->
+ List.map
+ (function
+ None -> raise (Failure ("NULL found in a table"))
+ | Some v -> v
+ ) (Array.to_list a)
+ ) (Mysql.exec c q)
+
+let quote s =
+ let rec quote_aux s =
+ try
+ let l = String.length s in
+ let i = String.index s '\'' in
+ String.sub s 0 i ^ "\\'" ^ quote_aux (String.sub s (succ i) (l - (succ i)))
+ with Not_found -> s
+ in
+ "'" ^ quote_aux s ^ "'"
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+type connection
+
+val init : string -> connection option
+
+val close : connection option -> unit
+
+val exec : connection option -> string -> string list list
+
+val quote : string -> string
(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
*)
+type connection = Postgres.connection
+
let init connection_string =
try Some (new Postgres.connection connection_string)
with _ -> raise (Failure ("MQIPostgres.init: " ^ connection_string))
(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
*)
-val init : string -> Postgres.connection option
+type connection
-val close : Postgres.connection option -> unit
+val init : string -> connection option
-val exec : Postgres.connection option -> string -> string list list
+val close : connection option -> unit
+
+val exec : connection option -> string -> string list list
val quote : string -> string
*)
module M = MathQL
-module P = MQIPostgres
+module P = MQIDataBase
module C = MQIConn
module U = MQIUtil
module A = MQIMap