Database class for PostgreSQL databases used with Sequel and the pg, postgres, or postgres-pr driver.
Connects to the database. In addition to the standard database options, using the :encoding or :charset option changes the client encoding for the connection.
# File lib/sequel/adapters/postgres.rb, line 196 def connect(server) opts = server_opts(server) conn = Adapter.connect( (opts[:host] unless blank_object?(opts[:host])), opts[:port] || 5432, nil, '', opts[:database], opts[:user], opts[:password] ) if encoding = opts[:encoding] || opts[:charset] if conn.respond_to?(:set_client_encoding) conn.set_client_encoding(encoding) else conn.async_exec("set client_encoding to '#{encoding}'") end end conn.db = self conn.apply_connection_settings conn end
Return instance of Sequel::Postgres::Dataset with the given options.
# File lib/sequel/adapters/postgres.rb, line 219 def dataset(opts = nil) Postgres::Dataset.new(self, opts) end
Execute the given SQL with the given args on an available connection.
# File lib/sequel/adapters/postgres.rb, line 224 def execute(sql, opts={}, &block) check_database_errors do return execute_prepared_statement(sql, opts, &block) if Symbol === sql synchronize(opts[:server]){|conn| conn.execute(sql, opts[:arguments], &block)} end end
Insert the values into the table and return the primary key (if automatically generated).
# File lib/sequel/adapters/postgres.rb, line 233 def execute_insert(sql, opts={}) return execute(sql, opts) if Symbol === sql check_database_errors do synchronize(opts[:server]) do |conn| conn.execute(sql, opts[:arguments]) insert_result(conn, opts[:table], opts[:values]) end end end
Generated with the Darkfish Rdoc Generator 2.