module PostgreSQLCursor
lib/postgresql_cursor/active_record/connection_adapters/postgresql_type_map
Defines extension to ActiveRecord/AREL to use this library
PostgreSQLCursor: library class provides postgresql cursor for large result set processing. Requires ActiveRecord
, but can be adapted to other DBI/ORM libraries. If you don't use AR, this assumes connection and instantiate methods are available.
options - Hash to control operation and loop breaks
connection: instance - ActiveRecord connection to use fraction: 0.1..1.0 - The cursor_tuple_fraction (default 1.0) block_size: 1..n - The number of rows to fetch per db block fetch while: value - Exits loop when block does not return this value. until: value - Exits loop when block returns this value. with_hold: boolean - Allows the query to remain open across commit points. cursor_name: string - Allows you to name your cursor.
Exmaples:
PostgreSQLCursor::Cursor.new("select ...").each { |hash| ... } ActiveRecordModel.where(...).each_row { |hash| ... } ActiveRecordModel.each_row_by_sql("select ...") { |hash| ... } ActiveRecordModel.each_instance_by_sql("select ...") { |model| ... }