Class: DB::MariaDB::Connection
- Inherits:
-
Async::Pool::Resource
- Object
- Async::Pool::Resource
- DB::MariaDB::Connection
- Defined in:
- lib/db/mariadb/connection.rb
Overview
This implements the interface between the underyling native interface interface and “standardised” connection interface.
Instance Method Summary collapse
- #append_identifier(value, buffer = String.new) ⇒ Object
- #append_literal(value, buffer = String.new) ⇒ Object
- #append_string(value, buffer = String.new) ⇒ Object
- #call(statement, streaming: false) ⇒ Object
- #close ⇒ Object
-
#initialize(**options) ⇒ Connection
constructor
A new instance of Connection.
- #next_result ⇒ Object
- #send_query(statement) ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(**options) ⇒ Connection
36 37 38 39 40 |
# File 'lib/db/mariadb/connection.rb', line 36 def initialize(**) @native = Native::Connection.connect(**) super() end |
Instance Method Details
#append_identifier(value, buffer = String.new) ⇒ Object
71 72 73 74 75 |
# File 'lib/db/mariadb/connection.rb', line 71 def append_identifier(value, buffer = String.new) buffer << "`" << @native.escape(value) << "`" return buffer end |
#append_literal(value, buffer = String.new) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/db/mariadb/connection.rb', line 54 def append_literal(value, buffer = String.new) case value when Numeric buffer << value.to_s when TrueClass buffer << 'TRUE' when FalseClass buffer << 'FALSE' when nil buffer << 'NULL' else append_string(value, buffer) end return buffer end |
#append_string(value, buffer = String.new) ⇒ Object
48 49 50 51 52 |
# File 'lib/db/mariadb/connection.rb', line 48 def append_string(value, buffer = String.new) buffer << "'" << @native.escape(value) << "'" return buffer end |
#call(statement, streaming: false) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/db/mariadb/connection.rb', line 89 def call(statement, streaming: false) @native.send_query(statement) last_result = nil while result = @native.next_result last_result = result end return last_result end |
#close ⇒ Object
42 43 44 45 46 |
# File 'lib/db/mariadb/connection.rb', line 42 def close @native.close super end |
#next_result ⇒ Object
85 86 87 |
# File 'lib/db/mariadb/connection.rb', line 85 def next_result @native.next_result end |
#send_query(statement) ⇒ Object
81 82 83 |
# File 'lib/db/mariadb/connection.rb', line 81 def send_query(statement) @native.send_query(statement) end |
#status ⇒ Object
77 78 79 |
# File 'lib/db/mariadb/connection.rb', line 77 def status @native.status end |