Skip to content

Instantly share code, notes, and snippets.

@komsit37
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save komsit37/5a867c6ce253daffd505 to your computer and use it in GitHub Desktop.

Select an option

Save komsit37/5a867c6ce253daffd505 to your computer and use it in GitHub Desktop.
migrate hdb from old server to new server. runs this in new server
//run this on q session in a new server
h: hopen`$":192.241.231.75:5012::";
h ({tables `.}; ());
sel: {[t; d] select from t where date=d};
getdata: {[src; dst; query; transform; d] dst set transform delete date from h (query; src; d)};
write: {[dst; d] .Q.dpft[`:/apps/bnb/data; d; `id; dst]};
d: 2015.01.12;
//booking
getdata[`booking;`booking; sel; {select id, time, on: cal, (`book`cancel!`book`open) action, price from x}] d;
write[`booking] d;
//booking2
//getdata[`booking2;`booking2; sel; ::] d
getdata[`booking2;`booking2; sel; {flip "stsddiif"$flip select id, time, (`book`cancel!`book`open) action, checkin, checkout, nights, rev, adr:revpar from x}] d;
write[`booking2] d;
//prop
getdata[`prop;`prop; sel; ::] d;
write[`prop;] d;
//search
getdata[`search;`search; sel; ::] d;
write[`search] d;
//future //previously cal
getdata[`cal;`future; {[t; d] select from t where date=d, cal >= date}; `id`time`on xcol] d;
write[`future] d;
hclose h;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment