Erlang/OTP Forums

Author Message

<  Erlyweb mailing list  ~  Postgres

Guest
Posted: Sun Mar 23, 2008 10:16 pm Reply with quote
Guest
I'm trying to get the postgresql interface working. I can't seem to
find too much on details on how to use it. In looking through the
code, I see erlydb:start(psql) does not exist for a match, so I get a
driver_not_supported error. I see I can manually do the
application:start for this, but should I?

Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
Guest
Posted: Sun Mar 23, 2008 10:23 pm Reply with quote
Guest
Also, when I do the application:(load/start) on my own (after
modifying the psql.app file) it simply hangs there. I can see a
connection has started on the Db side and when I explicitly kill it I
can see an unexpected EOF error in the postgres log.

On Mar 23, 6:15
ketralnis
Posted: Mon Mar 24, 2008 3:42 am Reply with quote
User Joined: 20 Jul 2007 Posts: 151 Location: San Francisco, CA
> I'm trying to get the postgresql interface working. I can't seem to
> find too much on details on how to use it. In looking through the
> code, I see erlydb:start(psql) does not exist for a match, so I get a
> driver_not_supported error. I see I can manually do the
> application:start for this, but should I?

The erlydb support for Postgres is terrible, bad enough that I've
stopped my attempt to migrate to it from mnesia and am going back. The
in-between state is a frustrating one, and is the primary reason that
development of my application has stagnated. Error messages are non-
existent or misleading, and the usual result of doing something,
anything, wrong is a hang on starting psql or on the first erlydb
access.

That said, here's how I got it to work. I have a wrotit.app (whose
contents aren't important), and then I start wrotit with
application:start(wrotit), and the following:

------- psql.app -------
{application,
psql, [
{description, "psql $Rev$"},
{vsn, "0.0.2"},
{registered, [psql_sup]},
{applications, [kernel, stdlib]},
{mod, {psql, []}},
{env, [{erlydb_psql, {"localhost",
5432,
"wrotit", "password",
"wrotit_db"}},
{pools, [{erlydb_psql, 5}]}]}
]}.

------- wrotit.erl -------

-module(wrotit).
-behavior(application).

-export([start/2, start/0,
stop/1,
compile/0, compile/1]).

-compile(export_all).

start() -> start([],[]).
start(_Type, _Args) ->
%% compile first (if nothing else, this at least loads in my
%% modules)
compile(),

%% bring up yaws (doesn't appear in my supervisor hierarchy)
wrotit_init:start_yaws(),

%% bring up psql, required by erlydb_psql
start_psql_driver(),

%% my main supervisor will be returned
wrotit_supervisor:start_link().

start_psql_driver() ->
case is_loaded(psql) of
true ->
ok;
false ->
application:start(psql)
end.

is_loaded(App) ->
lists:keymember(App,1,application:which_applications()).

stop(_State) ->
ok=yaws:stop(),
ok=psql:stop(),
ok.

compile() ->
compile([]).
compile(ExtraOptions) ->
%% read in wrotit.app
application:load(wrotit),
start_psql_driver(),
Options=[native,
debug_info,
{erlydb_driver,psql},
{auto_compile,wrotit_config:dev_mode()},
{i,wrotit_config:yaws_include()},
{allow_unsafe_statements,true},
{last_compile_time,auto}] ++ ExtraOptions,
code:add_paths([wrotit_config:yaws_ebin(),
wrotit_config:erlyweb_ebin(),
wrotit_config:plists_ebin()]),
erlyweb:compile(wrotit_config:appdir(),Options).


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message AIM Address
Guest
Posted: Mon Mar 24, 2008 3:02 pm Reply with quote
Guest
After some quick debugging, it seems to be stuck on a 'receive' in on
line 78 of psql_connection. What versions of postgres is this module
made for? Perhaps I'm using a new version that doesn't send back a
response.




On Mar 23, 2008, at 11:41 PM, David King wrote:
>
>> I'm trying to get the postgresql interface working. I can't seem to
>> find too much on details on how to use it. In looking through the
>> code, I see erlydb:start(psql) does not exist for a match, so I get a
>> driver_not_supported error. I see I can manually do the
>> application:start for this, but should I?
>
> The erlydb support for Postgres is terrible, bad enough that I've
> stopped my attempt to migrate to it from mnesia and am going back. The
> in-between state is a frustrating one, and is the primary reason that
> development of my application has stagnated. Error messages are non-
> existent or misleading, and the usual result of doing something,
> anything, wrong is a hang on starting psql or on the first erlydb
> access.
>
> That said, here's how I got it to work. I have a wrotit.app (whose
> contents aren't important), and then I start wrotit with
> application:start(wrotit), and the following:
>
> ------- psql.app -------
> {application,
> psql, [
> {description, "psql $Rev$"},
> {vsn, "0.0.2"},
> {registered, [psql_sup]},
> {applications, [kernel, stdlib]},
> {mod, {psql, []}},
> {env, [{erlydb_psql, {"localhost",
> 5432,
> "wrotit", "password",
> "wrotit_db"}},
> {pools, [{erlydb_psql, 5}]}]}
> ]}.
>
> ------- wrotit.erl -------
>
> -module(wrotit).
> -behavior(application).
>
> -export([start/2, start/0,
> stop/1,
> compile/0, compile/1]).
>
> -compile(export_all).
>
> start() -> start([],[]).
> start(_Type, _Args) ->
> %% compile first (if nothing else, this at least loads in my
> %% modules)
> compile(),
>
> %% bring up yaws (doesn't appear in my supervisor hierarchy)
> wrotit_init:start_yaws(),
>
> %% bring up psql, required by erlydb_psql
> start_psql_driver(),
>
> %% my main supervisor will be returned
> wrotit_supervisor:start_link().
>
> start_psql_driver() ->
> case is_loaded(psql) of
> true ->
> ok;
> false ->
> application:start(psql)
> end.
>
> is_loaded(App) ->
> lists:keymember(App,1,application:which_applications()).
>
> stop(_State) ->
> ok=yaws:stop(),
> ok=psql:stop(),
> ok.
>
> compile() ->
> compile([]).
> compile(ExtraOptions) ->
> %% read in wrotit.app
> application:load(wrotit),
> start_psql_driver(),
> Options=[native,
> debug_info,
> {erlydb_driver,psql},
> {auto_compile,wrotit_config:dev_mode()},
> {i,wrotit_config:yaws_include()},
> {allow_unsafe_statements,true},
> {last_compile_time,auto}] ++ ExtraOptions,
> code:add_paths([wrotit_config:yaws_ebin(),
> wrotit_config:erlyweb_ebin(),
> wrotit_config:plists_ebin()]),
> erlyweb:compile(wrotit_config:appdir(),Options).
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
Guest
Posted: Mon Mar 24, 2008 3:58 pm Reply with quote
Guest
hi,

On Mar 24, 4:01 pm, orb...@ezabel.com wrote:
> After some quick debugging, it seems to be stuck on a 'receive' in on
> line 78 of psql_connection. What versions of postgres is this module
> made for? Perhaps I'm using a new version that doesn't send back a
> response.

i was just struggling with erlydb_psql myself today. there are very
useful pointers in this blog post: http://www.cestari.info/2007/7/25/erlyweb-et-postgres
(albeit in french).

it seems you absolutely must use md5 authentication in your
pg_hba.conf - i was using trust for connections from localhost and it
worked fine for the psql commandline client, but erlydb_psql would
just hang as you describe. afterwards it just worked.

also, it seems you need to change line 312 of src/erlsql/erlsql.erl
from

[<<" LIMIT ">>, encode(Offset), $, , encode(Num)];

to

[<<" LIMIT ">>, encode(Num),<<" OFFSET ">> , encode(Offset)];

good luck! i am also online on irc as lefant on #erlyweb@freenode if
you want to chat.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
martin
Posted: Wed May 21, 2008 10:56 am Reply with quote
User Joined: 06 Aug 2006 Posts: 11
Hi all,

There is a new version of the driver available for download on:
http://www.erlang-consulting.com/erlang/opensource.html.

Fixes the silent boot-up when authentication fail as well as a bug where only one connection was created towards the database regardless of what the pool size was.

Note:
Make sure the database uses MD5 authentication or you will not be able to authenticate. This is a limitation in the driver.

//Martin
View user's profile Send private message
rbucker881
Posted: Sun May 25, 2008 2:12 pm Reply with quote
User Joined: 11 Oct 2007 Posts: 17
The URL martin linked to fails because it has a trailing '.', however, once I made it to the opensource page; the file(s) in question were dated 2006 and not the expected 2008.

/r
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum