Created
March 17, 2016 19:39
-
-
Save smondet/15c0e187ed438ef3a965 to your computer and use it in GitHub Desktop.
Create a Trakeva-friendly SQL query to archive nodes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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