On Saturday, September 28, 2013 7:39:51 PM UTC-7, Rob Sullivan wrote:

> gems:
> pg (0.17.0)
> sequel_pg (1.6.8)
> sequel (4.2.0)
>
> I'm trying to set my application_name in my connection string like so:
>
> DB = Sequel.connect(:adapter=>'postgres', :host=> 'localhost', 
> :database=>'blah', :user=>'gator', :application_name => 'blahwebapp')
>
> Even if I use the connection url (that works in psql) it still won't 
> register the application name properly in pg_stat_activity:
>
> DB = 
> Sequel.connect('postgres://gator@localhost/blah?application_name=blahwebapp')
>
> Regardless of what I do, the application_name defaults to the path of the 
> webserver:
> /Users/gator/.rvm/gems/rub...47@blahwebapp/bin/shotgun
>
> Any thoughts on what I can do or what I'm doing wrong on this?
>

Sequel's postgres adapter doesn't pass the URL directly to PostgreSQL.  It 
can't really do so and keep backwards compatibility.  

It looks like you can just set application_name at runtime.  The best way 
to do this with Sequel is via after_connect:

  DB = Sequel.connect('postgres://gator@localhost/blah', 
:after_connect=>{|c| c.execute("SET application_name TO 'blahwebapp'")})

It is possible to integrate this feature into sequel so that using it 
inside the postgres:// URL would work correctly.  I'm open to that if other 
people think it would be useful.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to