5 module G
= Demo_caml_gen_mysql.Sqlgg
(Sqlgg_mysql.Make
(Int64
))
8 let db = M.quick_connect ~database
:"test" ~user
:"root" () in
17 (* add all person records *)
18 G.add_person
db "John" "Black";
19 let john = M.insert_id
db in
20 G.add_person
db "Ivan" "Petrov";
21 let ivan = M.insert_id
db in
22 G.add_person
db "Sancho" "Alvares";
23 let sancho = M.insert_id
db in
25 (* add money relations *)
26 G.add_money
db john ivan 200L;
27 G.add_money
db ~src
:john ~dst
:sancho ~amount
:100L;
28 G.add_money
db ~amount
:250L ~dst
:sancho ~src
:john;
29 G.add_money
db sancho ivan 300L;
31 (* summarize by person and output *)
32 print_endline
"Total transfers:";
33 G.calc_total
db (printf
"%s = %Lu\n");
36 print_endline
"Donors:";
37 G.list_donors
db "petrov" 100L print_endline
;
39 (* properly close database *)
44 let () = Printexc.print
main ()