anchor.diff:    {ok, {LocalIP, LocalPort}} = inet:sockname(Socket),
     Query = "
     with data_id as (
  -    insert into data.connections (protocol, type)
  -      values ($1, 'ip')
  +    insert into data.connections (id, protocol, type)
  +      values ($1, $2, 'ip')
         returning id
     ) insert into connections.ip_data
  -      select D.id, $2, $3, $4, $5
  +      select D.id, $3, $4, $5, $6
           from data_id D returning id",
  -  S = execute(1000, execute, {Query, [Proto, LocalIP, LocalPort, RemoteIP, RemotePort]}, Timeout),
  +  ConnectionId = now2id(),
  +  S = execute(1000, execute, {Query, [ConnectionId, Proto, LocalIP, LocalPort, RemoteIP, RemotePort]}, Timeout),
     debug ("returned ~w", [S]),
     {ok, ConnectionID} = S,
     hooks:set(Pid, connection_id, ConnectionID),
  
positive.code:     ->
    {ok, 0};
  insert_terminal_raw_packet(RawID, RawPacket, Type, Timeout) ->
    execute(1000, insert, {data, packets, [{raw_id, RawID}, {data, RawPacket}, {type, Type}]}, Timeout).
  
  
  insert_terminal_packet(PacketID, _Module, Type, _Table, _Packet, _Timeout)
  
negative.code: insert_terminal_packet_set_data(PacketID, Module, SetName, [{N, Value} | Else], Timeout) ->
    execute(1000, insert, {Module, SetName, [{id, PacketID}, {sensor, N}, {value, Value}]}, Timeout),
    insert_terminal_packet_set_data(PacketID, Module, SetName, Else, Timeout).
  
  now2id() ->
    Now = {_, _, MicroSec} = erlang:now(),
    {Date, {H, M, S}} = calendar:now_to_universal_time(Now),
    {Date, {H, M, S + MicroSec/1000000}}.
  