Method: Sequel::Database#uri

Defined in:
lib/sequel/database.rb

#uriObject

Returns the URI identifying the database. This method can raise an error if the database used options instead of a connection string.



558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
# File 'lib/sequel/database.rb', line 558

def uri
  uri = URI::Generic.new(
    self.class.adapter_scheme.to_s,
    nil,
    @opts[:host],
    @opts[:port],
    nil,
    "/#{@opts[:database]}",
    nil,
    nil,
    nil
  )
  uri.user = @opts[:user]
  uri.password = @opts[:password] if uri.user
  uri.to_s
end