connectator 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
connectator
|
2
|
-
|
3
|
-
|
1
|
+
# Connectator [![Build Status](https://travis-ci.org/jamin4jc/connectator.png?branch=master)](https://travis-ci.org/jamin4jc/connectator)
|
2
|
+
|
4
3
|
Multi-Connection proxy for DBI
|
5
4
|
|
6
|
-
|
5
|
+
## Notes
|
7
6
|
|
8
7
|
*This gem is currently using the older DBI gem.*
|
9
8
|
https://github.com/erikh/ruby-dbi
|
@@ -11,33 +10,34 @@ https://github.com/erikh/ruby-dbi
|
|
11
10
|
This will at some point in the future change to use the new rdbi gem.
|
12
11
|
https://github.com/RDBI/rdbi
|
13
12
|
|
14
|
-
|
13
|
+
### Oracle
|
15
14
|
|
16
15
|
* Uses the ruby-oci8 gem directly
|
17
16
|
* Note that this gem does not directly require the ruby-oci8 gem. If you need
|
18
17
|
to use Oracle, include the ruby-oci8 gem in your project.
|
19
18
|
|
20
|
-
|
19
|
+
### Sql Server/Sybase
|
21
20
|
|
22
21
|
* Uses DBI:ODBC
|
23
22
|
* In order to use SQL Server/Sybase with Connectator, you will need to set up
|
24
23
|
Unix ODBC and FreeTDS. Unix ODBC will need to reference FreeTDS as one of its
|
25
24
|
drivers.
|
26
25
|
|
27
|
-
|
26
|
+
### MySQL
|
28
27
|
|
29
28
|
* Uses DBI:ODBC
|
30
29
|
* In order to use MySQL with Connectator, you will need to set up Unix ODBC and
|
31
30
|
the MySQL client. Unix ODBC will need to reference the MySQL driver as one of
|
32
31
|
its drivers.
|
32
|
+
* On Ubuntu, use package: libmyodbc
|
33
33
|
|
34
|
-
|
34
|
+
### DB2
|
35
35
|
|
36
36
|
* Uses DBI:DB2
|
37
37
|
* In order to use DB2 with Connectator, you will need to set up Unix ODBC and
|
38
38
|
the DB2 client. Unix ODBC will need to reference the DB2 driver as one of its
|
39
39
|
drivers.
|
40
40
|
|
41
|
-
|
41
|
+
## UNIX ODBC
|
42
42
|
|
43
43
|
See example_odbcinst.ini for a sample of what the /etc/odbcinst.ini should look like.
|
data/example_odbcinst.ini
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
|
3
1
|
module Connectator
|
4
2
|
module Base
|
5
3
|
class Connection
|
@@ -20,7 +18,7 @@ module Connectator
|
|
20
18
|
end
|
21
19
|
|
22
20
|
def system_connection
|
23
|
-
@system_connection ||= DBIProxy.new(open)
|
21
|
+
@system_connection ||= Connectator::Base::DBIProxy.new(open)
|
24
22
|
end
|
25
23
|
|
26
24
|
# proxies all other method calls to the DBIProxy
|
@@ -60,7 +58,7 @@ module Connectator
|
|
60
58
|
end
|
61
59
|
|
62
60
|
def connection_params_list
|
63
|
-
connection_params_hash.map { |k,v| "#{k}=#{v}"}.join(';')
|
61
|
+
connection_params_hash.reject {|k,v| v.nil? }.map { |k,v| "#{k}=#{v}"}.join(';')
|
64
62
|
end
|
65
63
|
|
66
64
|
def connection_params_hash
|
@@ -4,9 +4,10 @@ module Connectator
|
|
4
4
|
|
5
5
|
def initialize(opts = {})
|
6
6
|
connection_params.driver = 'MySQL'
|
7
|
+
# See this url for options flags
|
8
|
+
# http://dev.mysql.com/doc/refman/5.0/en/connector-odbc-configuration-connection-parameters.html#codbc-dsn-option-flags
|
7
9
|
connection_params.option = opts[:option] || '3'
|
8
|
-
connection_params.
|
9
|
-
connection_params.database = opts[:database] || ''
|
10
|
+
connection_params.database = opts[:database] || nil
|
10
11
|
super(opts)
|
11
12
|
end
|
12
13
|
|
@@ -19,12 +20,12 @@ module Connectator
|
|
19
20
|
def connection_params_hash
|
20
21
|
{
|
21
22
|
"DRIVER" => connection_params.driver,
|
22
|
-
"
|
23
|
-
"
|
24
|
-
"
|
25
|
-
"
|
26
|
-
"
|
27
|
-
"
|
23
|
+
"SERVER" => connection_params.server,
|
24
|
+
"PORT" => connection_params.port,
|
25
|
+
"DATABASE" => connection_params.database,
|
26
|
+
"UID" => connection_params.username,
|
27
|
+
"PWD" => connection_params.password,
|
28
|
+
"OPTION" => connection_params.option
|
28
29
|
}
|
29
30
|
end
|
30
31
|
end
|
data/lib/connectator/pinger.rb
CHANGED
data/lib/connectator.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
require 'dbi'
|
2
|
+
require 'timeout'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
require_relative 'connectator/base/connection'
|
6
|
+
require_relative 'connectator/base/dbi_proxy'
|
7
|
+
require_relative 'connectator/db2/connection'
|
8
|
+
require_relative 'connectator/mysql/connection'
|
9
|
+
require_relative 'connectator/oracle/connection'
|
10
|
+
require_relative 'connectator/sql/connection'
|
11
|
+
require_relative 'connectator/sql/connection/server_instance_string'
|
12
|
+
require_relative 'connectator/sybase/connection'
|
13
|
+
require_relative 'connectator/factory'
|
14
|
+
require_relative 'connectator/pinger'
|
@@ -20,21 +20,21 @@ describe Connectator::Mysql::Connection do
|
|
20
20
|
Then { connection.connection_params.username.should == 'User' }
|
21
21
|
Then { connection.connection_params.password.should == 'Pass' }
|
22
22
|
Then { connection.connection_params.instance.should == 'Instance' }
|
23
|
-
Then { connection.connection_params.database.should ==
|
23
|
+
Then { connection.connection_params.database.should == nil }
|
24
24
|
Then { connection.connection_params.option.should == '3' }
|
25
25
|
|
26
26
|
Then { connection.connection_string.should ==
|
27
|
-
"DBI:ODBC:DRIVER=MySQL;
|
27
|
+
"DBI:ODBC:DRIVER=MySQL;SERVER=Server;PORT=Port;UID=User;PWD=Pass;OPTION=3" }
|
28
28
|
|
29
29
|
Then { connection.send(:connection_params_hash).should ==
|
30
30
|
{
|
31
31
|
"DRIVER" => 'MySQL',
|
32
|
-
"
|
33
|
-
"
|
34
|
-
"
|
35
|
-
"
|
36
|
-
"
|
37
|
-
"
|
32
|
+
"SERVER" => 'Server',
|
33
|
+
"PORT" => 'Port',
|
34
|
+
"DATABASE" => nil,
|
35
|
+
"UID" => 'User',
|
36
|
+
"PWD" => 'Pass',
|
37
|
+
"OPTION" => '3'
|
38
38
|
}
|
39
39
|
}
|
40
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: connectator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
segments:
|
151
151
|
- 0
|
152
|
-
hash:
|
152
|
+
hash: -707223795178079430
|
153
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
154
|
none: false
|
155
155
|
requirements:
|