Module: Ensql::SequelAdapter

Extended by:
Adapter
Defined in:
lib/ensql/sequel_adapter.rb

Overview

Implements the Adapter interface for Sequel. Requires a Sequel connection to be established. Uses the first connection found in Sequel::DATABASES. You may want to utilize the relevant extensions to make the most of deserialization and other database features.

require 'sequel'
DB = Sequel.connect('postgres://localhost/mydb')
DB.extend(:pg_json)
Ensql.adapter = Ensql::SequelAdapter

To stream rows, configure streaming on the connection and use Ensql::SQL#each_row

 DB = Sequel.connect('postgresql:/')
 DB.extension(:pg_streaming)
 DB.stream_all_queries = true
 Ensql.sql("select * from large_table").each_row do  |row|
   # This now yields each row in single-row mode.
   # The connection cannot be used for other queries while this is streaming.
 end

Method Summary

Methods included from Adapter

fetch_count, fetch_each_row, fetch_first_column, fetch_first_field, fetch_first_row, fetch_rows, literalize, run