Please, help find info about building on Erlang application what can print various info from Mnesia by Yaws
Best regards, and many thanks for help.
Now i solve by this code:
Mnesia query:
lookup_artists() ->
Fun = fun() ->
% mnesia:read({sensors,Id})
Query = #artists{ artist_id = '$1', artist = '$2', _ = '_'},
mnesia:select(artists, [{Query, [], ['$$']}])
end,
mnesia:transaction(Fun).
And YAWS file:
<html>
<h1>Test query</h1>
<erl>
out(A) ->
AddTd = fun(Val) ->
% {td, [], integer_to_list(Val)}
io:format("~n ~p:~p GET Request Response ~p ~n", [?MODULE, ?LINE, Val]),
case is_integer(Val) of
true -> {td, [], integer_to_list(Val)};
false -> {td, [], Val}
end
end,
AddTr = fun(Val) ->
{tr, [], lists:map(AddTd, Val)}
end,
{atomic, Accounts} = wmb2:lookup_artists(),
{ehtml, [{table, [],
lists:append([[{tr, [], [{td, [], "ID"},
{td, [], "Artist"}]}],
lists:map(AddTr, Accounts)])},
{p, [], {b, [], f("Total: ~w", [length(Accounts)])}}]}.
</erl>
<p><a href="index.yaws">Index</a></p>
</html>
Don't know ... it's good code or not, but working fine :)
Yaws is a webserver, Mnesia a DBMS. Now, you basically need to learn Erlang first, then, learn how to read, write, update and delete from a mnesia Database. Yaws and mnesia can run within the same erlang VM, after-all, mnesia comes packaged within every standard erlang release.
When you install yaws, under usual circumstances, it will use the installed Erlang VM to run on, and in that same instance, you are able to start mnesia and do what you want. Your question is rather broad/vague, but, i guess i will just send you to an erlang book.