Class: Cmap::SqlRunner
- Inherits:
-
Object
- Object
- Cmap::SqlRunner
- Defined in:
- lib/cmap/sql_runner.rb
Instance Attribute Summary collapse
-
#db_config ⇒ Object
readonly
Returns the value of attribute db_config.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(db_config) ⇒ SqlRunner
constructor
A new instance of SqlRunner.
- #run_queries(queries) ⇒ Object
Constructor Details
#initialize(db_config) ⇒ SqlRunner
Returns a new instance of SqlRunner.
5 6 7 |
# File 'lib/cmap/sql_runner.rb', line 5 def initialize(db_config) @db_config = db_config end |
Instance Attribute Details
#db_config ⇒ Object (readonly)
Returns the value of attribute db_config.
3 4 5 |
# File 'lib/cmap/sql_runner.rb', line 3 def db_config @db_config end |
Instance Method Details
#connection ⇒ Object
15 16 17 |
# File 'lib/cmap/sql_runner.rb', line 15 def connection @connection ||= PGconn.connect(db_config) end |
#run_queries(queries) ⇒ Object
9 10 11 12 13 |
# File 'lib/cmap/sql_runner.rb', line 9 def run_queries(queries) queries.each do |q| connection.exec(q) end end |