Class: Marc2LinkedData::CapDb
- Inherits:
-
Object
- Object
- Marc2LinkedData::CapDb
- Defined in:
- lib/marc2linkeddata/cap_db.rb
Overview
An interface to an SQL database using Sequel
Constant Summary collapse
- @@log =
Logger.new('log/cap_db.log')
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
-
#db_config ⇒ Object
Returns the value of attribute db_config.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ CapDb
constructor
A new instance of CapDb.
Constructor Details
#initialize ⇒ CapDb
Returns a new instance of CapDb.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/marc2linkeddata/cap_db.rb', line 22 def initialize @db_config = {} @db_config['host'] = ENV['SUL_CAP_DB_HOST'] || 'localhost' @db_config['port'] = ENV['SUL_CAP_DB_PORT'] || '3306' @db_config['user'] = ENV['SUL_CAP_DB_USER'] || 'capUser' @db_config['password'] = ENV['SUL_CAP_DB_PASSWORD'] || 'capPass' @db_config['database'] = ENV['SUL_CAP_DB_DATABASE'] || 'cap' = @db_config.merge( { :encoding => 'utf8', :max_connections => 10, :logger => @@log }) @db = Sequel.mysql() @db.extension(:pagination) # Ensure the connection is good on startup, raises exceptions on failure puts "#{@db} connected: #{@db.test_connection}" end |
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db.
15 16 17 |
# File 'lib/marc2linkeddata/cap_db.rb', line 15 def db @db end |
#db_config ⇒ Object
Returns the value of attribute db_config.
16 17 18 |
# File 'lib/marc2linkeddata/cap_db.rb', line 16 def db_config @db_config end |
Class Method Details
.log_model_info(m) ⇒ Object
18 19 20 |
# File 'lib/marc2linkeddata/cap_db.rb', line 18 def self.log_model_info(m) @@log.info "table: #{m.table_name}, columns: #{m.columns}, pk: #{m.primary_key}" end |