anchor.diff:          ]),
           ?Info("tables ~p created", [[ddAdapter, ddInterface, ddConn, ddCmd, ddView, ddDash]]),
           Sess:run_cmd(insert, [ddInterface, #ddInterface{id = ddjson, fullName = <<"DDerl">>}]),
  -
           % Initializing adapters (all the *_adapter modules compiled with dderl)
           %  doesn't include dynamically built adapters
           {ok, AdaptMods} = application:get_key(dderl, modules),
  
positive.code:             {reply, ViewId, State};
          _ ->
              ?Error("Unable to get the view to update ~p", [ViewId]),
              {reply, {error, "Unable to get the view to update"}, State}
      end;
  
  handle_call({get_view, undefined, Name, Adapter, Owner}, From, #state{sess=Sess} = State) ->
  
negative.code:         ,is_local_query/1
          ]).
  
  -record(state, { schema :: term()
                 , sess :: {atom(), pid()}
      }).
  
  -spec login(binary(), binary()) -> {error, term()} | {true, {atom(), pid()}, ddEntityId()}.
  login(User, Password)                        -> gen_server:call(?MODULE, {login, User, Password}).
  
  -spec change_password(binary(), binary(), binary()) -> {error, term()} | {true, {atom(), pid()}, ddEntityId()}.
  change_password(User, Password, NewPassword) -> gen_server:call(?MODULE, {change_password, User, Password, NewPassword}).
  
  -spec add_adapter(atom(), binary()) -> ok.
  add_adapter(Id, FullName)           -> gen_server:cast(?MODULE, {add_adapter, Id, FullName}).
  
  -spec add_connect({atom(), pid()} | undefined, #ddConn{}) -> ok.
  add_connect(Sess, #ddConn{} = Conn) -> gen_server:cast(?MODULE, {add_connect, Sess, Conn}).
  
  -spec add_command({atom(), pid()} | undefined, ddEntityId(), atom(), binary(), binary(), atom(), term()) -> ddEntityId().
  add_command(Sess, Owner, Adapter, Name, Cmd, Conn, Opts) -> gen_server:call(?MODULE, {add_command, Sess, Owner, Adapter, Name, Cmd, Conn, Opts}).
  
  -spec update_command({atom(), pid()} | undefined, ddEntityId(), ddEntityId(), atom(), binary(), binary(), atom(), term()) -> ddEntityId().
  update_command(Sess, Id, Owner, Adapter, Name, Cmd, Conn, Opts) -> gen_server:call(?MODULE, {update_command, Sess, Id, Owner, Adapter, Name, Cmd, Conn, Opts}).
  
  -spec add_view({atom(), pid()} | undefined, ddEntityId(), binary(), ddEntityId(), #viewstate{}) -> ddEntityId().
  add_view(Sess, Owner, Name, CmdId, ViewsState) -> gen_server:call(?MODULE, {add_view, Sess, Owner, Name, CmdId, ViewsState}).
  
  -spec update_view({atom(), pid()}, integer(), #viewstate{}, binary()) -> integer() | {error, binary()}.
  update_view(Sess, ViewId, ViewsState, Qry) when is_integer(ViewId) -> gen_server:call(?MODULE, {update_view, Sess, ViewId, ViewsState, Qry}).
  
  -spec get_adapters({atom(), pid()}) -> [#ddAdapter{}].
  get_adapters(Sess) -> gen_server:call(?MODULE, {get_adapters, Sess}).
  
  -spec get_connects({atom(), pid()}, binary()) -> [#ddConn{}].
  get_connects(Sess, User) -> gen_server:call(?MODULE, {get_connects, Sess, User}).
  
  -spec del_conn({atom(), pid()}, ddEntityId()) -> ok | no_permission.
  del_conn(Sess, ConId) -> gen_server:call(?MODULE, {del_conn, Sess, ConId}).
  
  -spec get_command({atom(), pid()}, ddEntityId() | binary()) -> #ddCmd{}.
  get_command(Sess, IdOrName) -> gen_server:call(?MODULE, {get_command, Sess, IdOrName}).
  
  -spec get_view({atom(), pid()} | undefined, binary(), atom(), ddEntityId()) -> #ddView{}.
  get_view(Sess, Name, Adapter, Owner) -> gen_server:call(?MODULE, {get_view, Sess, Name, Adapter, Owner}).
  
  -spec hexstr_to_bin(binary()) -> binary().
  hexstr_to_bin(S) -> hexstr_to_bin(S, []).
  hexstr_to_bin([], Acc) -> list_to_binary(lists:reverse(Acc));
  hexstr_to_bin([X,Y|T], Acc) ->
      {ok, [V], []} = io_lib:fread("~16u", [X,Y]),
      hexstr_to_bin(T, [V | Acc]).
  
  -spec start_link(term()) -> {ok, pid()} | ignore | {error, term()}.
  start_link(SchemaName) ->
      ?Debug("starting...~n"),
      Result = gen_server:start_link({local, ?MODULE}, ?MODULE, [SchemaName], []),
  