anchor.diff:              From ! {reply, jsx:encode([{<<"error">>, <<"Connection not found">>}])},
               Priv
       end;
  -
   process_cmd({[<<"query">>], ReqBody}, Sess, _UserId, From, #priv{connections = Connections} = Priv, SessPid) ->
       [{<<"query">>,BodyJson}] = ReqBody,
       Query = proplists:get_value(<<"qstr">>, BodyJson, <<>>),
  
positive.code:     end,
      From ! {reply, RespJson},
      Priv;
  
  % open view by id
  process_cmd({[<<"open_view">>], ReqBody}, Sess, _UserId, From, #priv{connections = Connections} = Priv, SessPid) ->
      [{<<"open_view">>, BodyJson}] = ReqBody,
      ConnId = proplists:get_value(<<"conn_id">>, BodyJson, <<>>), %% This should be change to params...
  
negative.code:     Priv;
  process_cmd({[<<"drop_table">>], ReqBody}, _Sess, _UserId, From, #priv{connections = Connections} = Priv, _SessPid) ->
      [{<<"drop_table">>, BodyJson}] = ReqBody,
      TableNames = [sql_name(N) || N <- proplists:get_value(<<"table_names">>, BodyJson, [])],
      Results = [process_table_cmd(drop_table, TableName, BodyJson, Connections) || TableName <- TableNames],
      send_result_table_cmd(From, <<"drop_table">>, Results),
      Priv;
  process_cmd({[<<"truncate_table">>], ReqBody}, _Sess, _UserId, From, #priv{connections = Connections} = Priv, _SessPid) ->
      [{<<"truncate_table">>, BodyJson}] = ReqBody,
      TableNames = [sql_name(N) || N <- proplists:get_value(<<"table_names">>, BodyJson, [])],
      Results = [process_table_cmd(truncate_table, TableName, BodyJson, Connections) || TableName <- TableNames],
      send_result_table_cmd(From, <<"truncate_table">>, Results),
      Priv;
  process_cmd({[<<"snapshot_table">>], ReqBody}, _Sess, _UserId, From, #priv{connections = Connections} = Priv, _SessPid) ->
      [{<<"snapshot_table">>, BodyJson}] = ReqBody,
      TableNames = [sql_name(N) || N <- proplists:get_value(<<"table_names">>, BodyJson, [])],
      Results = [process_table_cmd(snapshot_table, TableName, BodyJson, Connections) || TableName <- TableNames],
      send_result_table_cmd(From, <<"snapshot_table">>, Results),
      Priv;
  process_cmd({[<<"restore_table">>], ReqBody}, _Sess, _UserId, From, #priv{connections = Connections} = Priv, _SessPid) ->
      [{<<"restore_table">>, BodyJson}] = ReqBody,
      TableNames = [sql_name(N) || N <- proplists:get_value(<<"table_names">>, BodyJson, [])],
      Results = [process_table_cmd(restore_table, TableName, BodyJson, Connections) || TableName <- TableNames],
      send_result_table_cmd(From, <<"restore_table">>, Results),
      Priv;
  process_cmd({[<<"button">>], ReqBody}, _Sess, _UserId, From, Priv, _SessPid) ->
      [{<<"button">>,BodyJson}] = ReqBody,
      Statement = binary_to_term(base64:decode(proplists:get_value(<<"statement">>, BodyJson, <<>>))),
  