(** A SQL script run the way [sqlite3 -bail] runs one, through the [sql] engine over any catalog. *) (** The type for the way a statement fails. *) type failure = | Refused of Catalog.Error.t (** The statement's error, which sqlite3 reports in the same words. *) | Defect of exn (** An exception no sqlite3 error stands for. *) val run : ?on_statement:(string -> unit) -> Sql.t -> string -> on_row:(Catalog.Value.t list -> unit) -> (unit, failure) result (** [run ~on_statement db sql ~on_row] runs the statements of [sql] on [db] in order, handing [on_statement] the text of each before it runs (defaults to dropping it) and [on_row] each row of each [SELECT], and stops at the first that fails, with its failure. A statement is parsed only once the one before it has run, so a statement that does not parse fails after those before it have taken effect, as in sqlite3. *) val replay : Sql.t -> string list -> unit (** [replay db texts] runs each statement text of [texts] on [db], each whatever the one before it answered, and drops their rows: the texts {!run} handed [on_statement], run again over a fresh catalog, leave it as they left the one they first ran over. *) val pp_failure : failure Fmt.t (** [pp_failure] prints a refusal as sqlite3 words it, and a defect as [defect: ] followed by the exception. *)