anchor.diff:  
   -define(DB, sigma_sql_cached_db).
   
  +-type sql()         :: iolist().
  +-type sql_result()  :: any().
   -type db()          :: atom().
   -type table()       :: string() | atom().
   -type field()       :: string() | atom().
  
positive.code:     q(SQL),
      KeyValue.
  
  %% proplist query
  plq(Q) ->
      Db = db(),
      db_q(proplist,Db,Q).
  
  plq(Q,ParamList) ->
      Db = db(),
      db_q(proplist,Db,Q,ParamList).
  
  %% dict query
  dq(Q) ->
      Db = db(),
      db_q(dict,Db,Q).
  
  dq(Q,ParamList) ->
      Db = db(),
      db_q(dict,Db,Q,ParamList).
  
  %% tuple query
  tq(Q) ->
      Db = db(),
      db_q(tuple,Db,Q).
  
  tq(Q,ParamList) ->
      Db = db(),
      db_q(tuple,Db,Q,ParamList).
  
  format_result(Type,Res) ->
      Json = emysql_util:as_json(Res),
      case Type of
          list ->
              format_list_result(Json);
          tuple ->
              format_tuple_result(Json);
          proplist ->
              format_proplist_result(Json);
          dict ->
              format_dict_result(Json)
      end.
  
  format_value(null) ->
      undefined;
  format_value(V) when is_binary(V) ->
      binary_to_list(V);
  format_value(V) ->
      V.
  
  format_key(K) when is_atom(K) ->
      K;
  format_key(K) when is_binary(K) ->
      format_key(binary_to_list(K));
  format_key(K) when is_list(K) ->
      list_to_atom(K).
  
  format_list_result(Json) ->
      [
          [format_value(Value) || {_,Value} <- Row]
      || Row <- Json].
  
  format_tuple_result(Json) ->
      [list_to_tuple(Row) || Row <- format_list_result(Json)].
  
  format_proplist_result(Json) ->
      [
          [{format_key(F), format_value(V)} || {F,V} <- Row]
      || Row <-Json].
  
  format_dict_result(Json) ->
      [dict:from_list(PL) || PL <- format_proplist_result(Json)].
  
  %% Query from the specified Database pool (Db)
  %% This will connect to the specified Database Pool
  %% Type must be atoms: proplist, dict, list, or tuple
  %% Type can also be atom 'insert' in which case, it'll return the insert value
  
  db_q(Type,Db,Q) ->
      try 
          Res = emysql:execute(Db,Q),
  
negative.code:     TableFields = table_fields(Table),
      [{K,V} || {K,V} <- PropList,lists:member(atomize(K),TableFields)].
  
  -spec q(Q :: sql()) -> [list()].
  %% @doc Run the SQL query `Q` and return a list of lists, with each inner list
  %% representing one record in the return set.
  q(Q) ->
      Db = db(),
      db_q(list,Db,Q).
  
  -spec q(Q :: sql(), ParamList :: [value()]) -> [list()].
  %% @doc Run the SQL query `Q`, with the the values of `ParamList` safely
  %% injected into the query replacing any instances of question marks (`?`),
  %% with each inner list representing one record in the return set (same as q/1).
  q(Q,ParamList) ->
      Db = db(),
      db_q(list,Db,Q,ParamList).
  
  -spec dq(Q :: sql()) -> [dict()].
  %% @doc Same as q/1, but returns a list of dicts.
  dq(Q) ->
      Db = db(),
      db_q(dict,Db,Q).
  
  -spec dq(Q :: sql(), ParamList :: [value()]) -> [dict()].
  %% @doc Same as q/2, but returns a list of dicts
  dq(Q,ParamList) ->
      Db = db(),
      db_q(dict,Db,Q,ParamList).
  
  -spec tq(Q :: sql()) -> [tuple()].
  %% @doc Same as q/1, but returns a list of tuples
  tq(Q) ->
      Db = db(),
      db_q(tuple,Db,Q).
  
  -spec tq(Q :: sql(), ParamList :: [value()]) -> [tuple()].
  %% @doc Same as q/2, but returns a list of tuples
  tq(Q,ParamList) ->
      Db = db(),
      db_q(tuple,Db,Q,ParamList).
  
  -spec plq(Q :: sql()) -> [proplist()].
  %% @doc Same as q/1, but returns a list of proplists
  plq(Q) ->
      Db = db(), db_q(proplist,Db,Q).
  
  -spec plq(Q :: sql(), ParamList :: [value()]) -> [proplist()].
  %% @doc Same as q/2, but returns a list of proplists
  plq(Q,ParamList) ->
      Db = db(),
      db_q(proplist,Db,Q,ParamList).
  
  -spec pli(Table :: table(), PropList :: proplist()) -> insert_id().
  %% @doc Inserts a proplist into the table
  pli(Table,PropList) when is_atom(Table) ->
      pli(atom_to_list(Table),PropList);
  pli(Table,InitPropList) ->
  