Class: MonetDB::Connection
- Inherits:
-
Object
- Object
- MonetDB::Connection
- Defined in:
- lib/monetdb/connection.rb,
lib/monetdb/connection/io.rb,
lib/monetdb/connection/query.rb,
lib/monetdb/connection/setup.rb,
lib/monetdb/connection/logger.rb,
lib/monetdb/connection/messages.rb,
lib/monetdb/connection/query/table.rb
Defined Under Namespace
Modules: IO, Logger, Messages, Query, Setup
Constant Summary collapse
- Q_TABLE =
SELECT statement
"1"- Q_UPDATE =
INSERT/UPDATE statement
"2"- Q_CREATE =
CREATE/DROP TABLE statement
"3"- Q_TRANSACTION =
TRANSACTION
"4"- Q_PREPARE =
QPREPARE message
"5"- Q_BLOCK =
QBLOCK message
"6"- MSG_PROMPT =
""- MSG_ERROR =
"!"- MSG_REDIRECT =
"^"- MSG_QUERY =
"&"- MSG_SCHEME =
"%"- MSG_TUPLE =
"["- ENDIANNESS =
"BIG"- LANG =
"sql"- REPLY_SIZE =
"-1"- MAX_MSG_SIZE =
32766- MAPI_V8 =
"8"- MAPI_V9 =
"9"- PROTOCOLS =
[MAPI_V8, MAPI_V9]
- AUTH_MD5 =
"MD5"- AUTH_SHA512 =
"SHA512"- AUTH_SHA384 =
"SHA384"- AUTH_SHA256 =
"SHA256"- AUTH_SHA1 =
"SHA1"- AUTH_PLAIN =
"PLAIN"- AUTH_TYPES =
[AUTH_MD5, AUTH_SHA512, AUTH_SHA384, AUTH_SHA256, AUTH_SHA1, AUTH_PLAIN]
Instance Method Summary collapse
- #check_connectivity! ⇒ Object
- #connect ⇒ Object
- #connected? ⇒ Boolean
- #disconnect ⇒ Object
-
#initialize(config = {}) ⇒ Connection
constructor
A new instance of Connection.
- #reconnect? ⇒ Boolean
Methods included from Query
included, #query, #select_value, #select_values
Constructor Details
#initialize(config = {}) ⇒ Connection
Returns a new instance of Connection.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/monetdb/connection.rb', line 48 def initialize(config = {}) @config = { :host => "localhost", :port => 50000, :username => "monetdb", :password => "monetdb" }.merge( config.inject({}){|h, (k, v)| h[k.to_sym] = v; h} ) end |
Instance Method Details
#check_connectivity! ⇒ Object
80 81 82 |
# File 'lib/monetdb/connection.rb', line 80 def check_connectivity! connect if reconnect? && !connected? end |
#connect ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/monetdb/connection.rb', line 59 def connect disconnect if connected? @socket = TCPSocket.new config[:host], config[:port].to_i socket.setsockopt Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true setup true end |
#connected? ⇒ Boolean
72 73 74 |
# File 'lib/monetdb/connection.rb', line 72 def connected? !socket.nil? end |
#disconnect ⇒ Object
67 68 69 70 |
# File 'lib/monetdb/connection.rb', line 67 def disconnect socket.close if connected? @socket = nil end |
#reconnect? ⇒ Boolean
76 77 78 |
# File 'lib/monetdb/connection.rb', line 76 def reconnect? !!config[:reconnect] end |