Class: DBGeni::Connector::Mysql
- Inherits:
-
Object
- Object
- DBGeni::Connector::Mysql
- Defined in:
- lib/dbgeni/connectors/mysql.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Class Method Summary collapse
Instance Method Summary collapse
- #commit ⇒ Object
- #date_as_string(dtm) ⇒ Object
- #date_placeholder(bind_var) ⇒ Object
- #disconnect ⇒ Object
- #execute(sql, *binds) ⇒ Object
- #ping ⇒ Object
- #rollback ⇒ Object
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
14 15 16 |
# File 'lib/dbgeni/connectors/mysql.rb', line 14 def connection @connection end |
#database ⇒ Object (readonly)
Returns the value of attribute database.
15 16 17 |
# File 'lib/dbgeni/connectors/mysql.rb', line 15 def database @database end |
Class Method Details
.connect(user, password, database, host, port) ⇒ Object
17 18 19 |
# File 'lib/dbgeni/connectors/mysql.rb', line 17 def self.connect(user, password, database, host, port) self.new(user, password, database, host, port=nil) end |
Instance Method Details
#commit ⇒ Object
44 45 46 |
# File 'lib/dbgeni/connectors/mysql.rb', line 44 def commit @connection.commit end |
#date_as_string(dtm) ⇒ Object
56 57 58 |
# File 'lib/dbgeni/connectors/mysql.rb', line 56 def date_as_string(dtm) dtm.strftime '%Y-%m-%d %H:%M:%S' end |
#date_placeholder(bind_var) ⇒ Object
52 53 54 |
# File 'lib/dbgeni/connectors/mysql.rb', line 52 def date_placeholder(bind_var) "?" # ":#{bind_var}" end |
#disconnect ⇒ Object
21 22 23 |
# File 'lib/dbgeni/connectors/mysql.rb', line 21 def disconnect @connection.close end |
#execute(sql, *binds) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/dbgeni/connectors/mysql.rb', line 25 def execute(sql, *binds) if RUBY_PLATFORM == 'java' execute_jdbc(sql, *binds) else execute_native(sql, *binds) end end |
#ping ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/dbgeni/connectors/mysql.rb', line 34 def ping results = self.execute('select 1 + 1 from dual') if results.length == 1 true else false end end |
#rollback ⇒ Object
48 49 50 |
# File 'lib/dbgeni/connectors/mysql.rb', line 48 def rollback @connection.rollback end |