Skip to content

Instantly share code, notes, and snippets.

@smondet
Created March 17, 2016 19:39
Show Gist options
  • Save smondet/15c0e187ed438ef3a965 to your computer and use it in GitHub Desktop.
Save smondet/15c0e187ed438ef3a965 to your computer and use it in GitHub Desktop.
Create a Trakeva-friendly SQL query to archive nodes.
#use "topfind";;
#thread;;
#require "ketrew";;
open Nonstd
module String = Sosa.Native_string
let escape_blob s =
let b = Buffer.create (String.length s * 2 + 4) in
Buffer.add_string b "X'";
String.iter s ~f:(fun c ->
Buffer.add_string b (sprintf "%02X" (int_of_char c));
);
Buffer.add_char b '\'';
Buffer.contents b
let finished_targets_collection = "finished-targets"
let archived_targets_collection = "archived-targets"
let () =
printf
"UPDATE trakeva_default_table SET collection = %s WHERE collection = %s \n%!"
(escape_blob archived_targets_collection)
(escape_blob finished_targets_collection)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment