Class | Sequel::Postgres::Adapter |
In: |
lib/sequel_core/adapters/postgres.rb
|
Parent: | ::PGconn |
PGconn subclass for connection specific methods used with the pg, postgres, or postgres-pr driver.
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.
# File lib/sequel_core/adapters/postgres.rb, line 121 121: def apply_connection_settings 122: super 123: if Postgres.use_iso_date_format 124: sql = "SET DateStyle = 'ISO'" 125: @db.log_info(sql) 126: execute(sql) 127: end 128: end
Execute the given SQL with this connection. If a block is given, yield the results, otherwise, return the number of changed rows.
# File lib/sequel_core/adapters/postgres.rb, line 132 132: def execute(sql, args=nil) 133: q = nil 134: begin 135: q = args ? async_exec(sql, args) : async_exec(sql) 136: rescue PGError 137: begin 138: s = status 139: rescue PGError 140: raise(Sequel::DatabaseDisconnectError) 141: end 142: status_ok = (s == Adapter::CONNECTION_OK) 143: status_ok ? raise : raise(Sequel::DatabaseDisconnectError) 144: ensure 145: block if status_ok 146: end 147: begin 148: block_given? ? yield(q) : q.cmd_tuples 149: ensure 150: q.clear 151: end 152: end