Class Sequel::Postgres::Adapter
In: lib/sequel/adapters/postgres.rb
Parent: ::PGconn

PGconn subclass for connection specific methods used with the pg, postgres, or postgres-pr driver.

Methods

Included Modules

Sequel::Postgres::AdapterMethods

Attributes

prepared_statements  [R]  Hash of prepared statements for this connection. Keys are string names of the server side prepared statement, and values are SQL strings.

Public Instance methods

Apply connection settings for this connection. Current sets the date style to ISO in order make Date object creation in ruby faster, if Postgres.use_iso_date_format is true.

[Source]

     # File lib/sequel/adapters/postgres.rb, line 131
131:       def apply_connection_settings
132:         super
133:         if Postgres.use_iso_date_format
134:           sql = "SET DateStyle = 'ISO'"
135:           @db.log_info(sql)
136:           execute(sql)
137:         end
138:         @prepared_statements = {} if SEQUEL_POSTGRES_USES_PG
139:       end

Execute the given SQL with this connection. If a block is given, yield the results, otherwise, return the number of changed rows.

[Source]

     # File lib/sequel/adapters/postgres.rb, line 143
143:       def execute(sql, args=nil)
144:         q = nil
145:         begin
146:           q = args ? async_exec(sql, args) : async_exec(sql)
147:         rescue PGError
148:           begin
149:             s = status
150:           rescue PGError
151:             raise(Sequel::DatabaseDisconnectError)
152:           end
153:           status_ok = (s == Adapter::CONNECTION_OK)
154:           status_ok ? raise : raise(Sequel::DatabaseDisconnectError)
155:         ensure
156:           block if status_ok
157:         end
158:         begin
159:           block_given? ? yield(q) : q.cmd_tuples
160:         ensure
161:           q.clear
162:         end
163:       end

[Validate]