b0VIM 7.3©5%OHº
defasgard~def/Work/Git/lkb-melodious/tools/from_json.mlutf-8
3210#"! Utp7ad%	
7íÓÒÇÀ®š–‚po>=+ÿþàßÊ›s:1å
¿
”
|
l
R


ÓÒÄ c\TóÑ¢nD(ý
í
¼
Š
‚
S
5
/
.


let () = main ()  end    in ignore (S.db_close db)    | _ -> prerr_endline "Invalid json schema"      )       | _ -> prerr_endline "Invalid song schema"       | (song, `Assoc tags) -> update song tags      (function    | `Assoc songs -> flip List.iter songs    let _ = match json with    let Effect update = update_song db in    let _ = S.exec db "PRAGMA SYNCHRONOUS = OFF" in    let _ = prerr_endline "Opened database" in    let db = S.db_open db_file in    let json = read_json json_file in    let json_file, db_file = Sys.argv.(1), Sys.argv.(2) in  begin  else    prerr_endline "Usage: from_json <file.json> <db.sqlite>"  if Array.length Sys.argv < 3 thenlet main () =       | (k, _) -> prerr_endline ("Unknown entry " ^ k)))           S.fold_query stmt_ins [songid; D.TEXT k; D.TEXT v] B.void       | (k,`String v) ->      (function    flip List.iter tags    S.fold_query stmt_del [songid] B.void;    let songid = S.id_to_data song in    let _ = prerr_endline ("Tagging " ^ song) in  Effect (fun song tags ->    ) in    , "INSERT INTO tags (song,key,value) VALUES (?,?,?)"    ( "DELETE FROM tags WHERE song = ?"  let stmt_del, stmt_ins = map2 (S.prepare db)let update_song db =type 'a effect = Effect of 'a  Json.pretty_to_channel ~std:true stdout jlet dump_json j =let read_json filename = Json.from_file filenamemodule D = S.Datamodule B = S.Bananaend  include Sql_utils  include Sqlite3structmodule S =module Json = Yojson.Safeopen Utils_generic