Is it possible to make the example on the `README.md` more obvious?
fmv1992 opened this issue · 1 comments
fmv1992 commented
This is a newbie question.
I can't figure out how to get example.erl
and example_worker.erl
to work.
I got:
Pid1 = example:start(),
Specs = example:init([]),
But what next? I'm able to connect to my epgsql
database using vanilla epgsql
.
It would be lovely if you could point out until:
example:squery("pool1", "SELECT 1;").
% Or is it 'pool1' (atom).
Thanks in advance!
fmv1992 commented
I was able to figure out. I added the following to example.erl
:
main() ->
% See if the database is working with plain `epgsql':
{ok, C} = epgsql:connect(#{
host => "localhost",
username => "u",
password => "p",
database => "d",
timeout => 4000
}),
{ok, _Z, __Z} = epgsql:squery(C, "SELECT 'epgsql...';"),
% Start to trigger `application:start(?MODULE).' This will allow `get_env'
% to not return `undefined'.
Pid1 = example:start(),
% Start the supervisor. This will also call `init'.
Pid2 = example:start([], []),
io_lib:format("~p", [example:squery(pool1, "SELECT 'POOLBOY!' as x;")]).
And I got the result of my query in the end.