Class: Ductr::Postgres::Adapter
- Inherits:
-
SequelBase::Adapter
- Object
- SequelBase::Adapter
- Ductr::Postgres::Adapter
- Defined in:
- lib/ductr/postgres/adapter.rb
Overview
The PostgreSQL adapter implement the required #open! and #close! methods to handle the database connection.
The adapter is registered as :postgres to use it, add adapter: postgres to the YAML configuration e.g.:
# config/development.yml
adapters:
some_postgres_database:
adapter: postgres
host: localhost
user: postgres
password: s3cr3t
database: example
Instance Method Summary collapse
-
#close! ⇒ void
Closes the database connection.
-
#new_connection ⇒ Sequel::Database
Open a new connection, ensure to close it with the #disconnect method.
-
#open! ⇒ Sequel::Database
Opens the database connection with the adapter's configuration.
Instance Method Details
#close! ⇒ void
This method returns an undefined value.
Closes the database connection.
42 43 44 |
# File 'lib/ductr/postgres/adapter.rb', line 42 def close! @db.disconnect end |
#new_connection ⇒ Sequel::Database
Open a new connection, ensure to close it with the #disconnect method.
51 52 53 54 55 56 57 58 |
# File 'lib/ductr/postgres/adapter.rb', line 51 def new_connection db = Sequel.postgres(**config) db.extension(:pg_streaming) db.stream_all_queries = true db end |
#open! ⇒ Sequel::Database
Opens the database connection with the adapter's configuration.
33 34 35 |
# File 'lib/ductr/postgres/adapter.rb', line 33 def open! @db = new_connection end |