Class: Makanai::Dbms::Postgres
- Defined in:
- lib/makanai/dbms/postgres.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
Instance Method Summary collapse
- #execute_sql(sql) ⇒ Object
-
#initialize(config) ⇒ Postgres
constructor
A new instance of Postgres.
Constructor Details
#initialize(config) ⇒ Postgres
Returns a new instance of Postgres.
8 9 10 11 12 |
# File 'lib/makanai/dbms/postgres.rb', line 8 def initialize(config) super() @db = PG.connect(config || default_config) db.type_map_for_results = PG::BasicTypeMapForResults.new(db) end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
14 15 16 |
# File 'lib/makanai/dbms/postgres.rb', line 14 def db @db end |
Instance Method Details
#execute_sql(sql) ⇒ Object
16 17 18 |
# File 'lib/makanai/dbms/postgres.rb', line 16 def execute_sql(sql) db.exec(sql).each.to_a.tap { close_db } end |