Class: OdbcConnection
- Inherits:
-
Object
- Object
- OdbcConnection
- Defined in:
- lib/dbexpect/odbc_connection.rb
Defined Under Namespace
Classes: DatabaseException
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(dsn, db_config) ⇒ OdbcConnection
constructor
A new instance of OdbcConnection.
- #run(stmt) ⇒ Object
Constructor Details
#initialize(dsn, db_config) ⇒ OdbcConnection
Returns a new instance of OdbcConnection.
25 26 27 28 29 30 31 32 33 |
# File 'lib/dbexpect/odbc_connection.rb', line 25 def initialize(dsn,db_config) @connection = ODBC.connect( db_config['database'], db_config['username'], db_config['password'] ) @type = db_config['type'] end |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
24 25 26 |
# File 'lib/dbexpect/odbc_connection.rb', line 24 def type @type end |
Instance Method Details
#run(stmt) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dbexpect/odbc_connection.rb', line 35 def run(stmt) return [] if stmt.empty? begin query = @connection.run(stmt) res = query.to_a query.drop rescue ODBC::Error => e raise DatabaseException.new(e.) end res end |