Class: Oculus::Connection::Mysql2
- Inherits:
-
Object
- Object
- Oculus::Connection::Mysql2
- Defined in:
- lib/oculus/connection/mysql2.rb
Instance Method Summary collapse
- #execute(sql) ⇒ Object
-
#initialize(options = {}) ⇒ Mysql2
constructor
A new instance of Mysql2.
- #kill(id) ⇒ Object
- #thread_id ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Mysql2
Returns a new instance of Mysql2.
6 7 8 |
# File 'lib/oculus/connection/mysql2.rb', line 6 def initialize( = {}) @connection = ::Mysql2::Client.new() end |
Instance Method Details
#execute(sql) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/oculus/connection/mysql2.rb', line 10 def execute(sql) results = @connection.query(sql) [results.fields] + results.map(&:values) if results rescue ::Mysql2::Error => e raise Connection::Error.new(e.) end |
#kill(id) ⇒ Object
17 18 19 |
# File 'lib/oculus/connection/mysql2.rb', line 17 def kill(id) execute("KILL QUERY #{id}") end |
#thread_id ⇒ Object
21 22 23 |
# File 'lib/oculus/connection/mysql2.rb', line 21 def thread_id @connection.thread_id end |