fluiddb 0.1.17 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/FluidDb/TinyTds.rb +41 -37
- metadata +7 -10
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d41ef8c88a11e0ece4a4eca92d8998cf387f7701
|
4
|
+
data.tar.gz: be7a7757cb029b40cf14e08065ef1a20597aa836
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d174b047e9a60d943d8086326495ccc37f4c7df2e3aeb4f2ccf575dfdcef28bda501e4e9508a5fd2f22a854e4b770fbbabdc8f033e2a072b234c80b023199223
|
7
|
+
data.tar.gz: 6c2edac4d0e036c57b0cfc3719973330030792071f882360b88f664083eee3e07e80cb8b5f74bca6c98aeed9421ac6f24062404066ee96936fa4d0295ca4a580
|
data/lib/FluidDb/TinyTds.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'FluidDb'
|
2
|
+
require 'tiny_tds'
|
3
|
+
require 'cgi'
|
4
4
|
|
5
5
|
module FluidDb
|
6
|
-
|
6
|
+
|
7
7
|
class TinyTds<Base
|
8
|
-
|
8
|
+
|
9
9
|
# Connect to Db.
|
10
10
|
#
|
11
11
|
# @param [String] uri a location for the resource to which we will attach, eg tinytds://<user>:<pass>@<dataserver>/<database>
|
@@ -13,28 +13,32 @@ module FluidDb
|
|
13
13
|
uri = @uri
|
14
14
|
|
15
15
|
dataserver = uri.host
|
16
|
-
database = uri.path.sub( "/",
|
16
|
+
database = uri.path.sub( "/", '' )
|
17
17
|
username = URI.unescape( uri.user )
|
18
18
|
password = uri.password
|
19
19
|
|
20
|
-
|
21
|
-
if dataserver ==
|
22
|
-
database ==
|
20
|
+
|
21
|
+
if dataserver == '' ||
|
22
|
+
database == '' then
|
23
23
|
raise "*** You need to specify both a dataserver and a database for the tinytds driver. Expected format: tinytds://<user>:<pass>@<dataserver>/<database>\n" +
|
24
24
|
"*** The specified dataserver should have an entry in /etc/freetds/freetds.conf"
|
25
25
|
end
|
26
|
-
|
27
|
-
if username ==
|
28
|
-
password ==
|
26
|
+
|
27
|
+
if username == '' ||
|
28
|
+
password == '' then
|
29
29
|
puts "*** Warning - you will normally need to specify both a username and password for the tinytds driver to work correctly."
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
hash = Hash[:username, username, :password, password, :database, database, :dataserver, dataserver]
|
33
33
|
failOverDataServer = nil
|
34
34
|
if !uri.query.nil? then
|
35
35
|
cgi = CGI.parse( uri.query )
|
36
36
|
hash[:timeout] = cgi["timeout"][0].to_i if cgi.has_key?( "timeout" )
|
37
|
-
|
37
|
+
if cgi.has_key( "host" )
|
38
|
+
hash.delete(:dataserver)
|
39
|
+
hash[:host] = dataserver
|
40
|
+
end
|
41
|
+
|
38
42
|
failOverDataServer = cgi["failoverdataserver"][0] if cgi.has_key?( "failoverdataserver" )
|
39
43
|
end
|
40
44
|
|
@@ -53,17 +57,17 @@ module FluidDb
|
|
53
57
|
raise e
|
54
58
|
end
|
55
59
|
end
|
56
|
-
|
60
|
+
|
57
61
|
if !@connection.active? then
|
58
62
|
raise "Unable to connect to the database"
|
59
63
|
end
|
60
|
-
|
64
|
+
|
61
65
|
end
|
62
|
-
|
66
|
+
|
63
67
|
def close
|
64
68
|
@connection.close
|
65
69
|
end
|
66
|
-
|
70
|
+
|
67
71
|
def escape_string( input )
|
68
72
|
return @connection.escape( input )
|
69
73
|
end
|
@@ -71,69 +75,69 @@ module FluidDb
|
|
71
75
|
def queryForArray( sql, params=[] )
|
72
76
|
sql = self.format_to_sql( sql, params )
|
73
77
|
results = @connection.execute(sql)
|
74
|
-
|
78
|
+
|
75
79
|
count = 0
|
76
|
-
tuple =
|
80
|
+
tuple = ''
|
77
81
|
results.each do |row|
|
78
82
|
count = count + 1
|
79
83
|
raise FluidDb::TooManyRowsError.new if count > 1
|
80
|
-
|
84
|
+
|
81
85
|
tuple = row
|
82
86
|
end
|
83
|
-
|
87
|
+
|
84
88
|
raise FluidDb::NoDataFoundError.new if count == 0
|
85
|
-
|
89
|
+
|
86
90
|
return tuple
|
87
91
|
end
|
88
|
-
|
92
|
+
|
89
93
|
def queryForValue( sql, params=[] )
|
90
94
|
sql = self.format_to_sql( sql, params )
|
91
95
|
results = @connection.execute(sql)
|
92
|
-
|
96
|
+
|
93
97
|
count = 0
|
94
|
-
value =
|
98
|
+
value = ''
|
95
99
|
results.each do |row|
|
96
100
|
count = count + 1
|
97
101
|
raise FluidDb::TooManyRowsError.new if count > 1
|
98
|
-
|
102
|
+
|
99
103
|
value = row[results.fields[0]]
|
100
104
|
end
|
101
|
-
|
105
|
+
|
102
106
|
raise FluidDb::NoDataFoundError.new if count == 0
|
103
|
-
|
107
|
+
|
104
108
|
return value
|
105
109
|
end
|
106
110
|
|
107
111
|
def queryForResultset( sql, params=[] )
|
108
112
|
sql = self.format_to_sql( sql, params )
|
109
113
|
results = @connection.execute(sql)
|
110
|
-
|
114
|
+
|
111
115
|
list = Array.new
|
112
116
|
results.each do |row|
|
113
117
|
list << row
|
114
118
|
end
|
115
|
-
|
119
|
+
|
116
120
|
return list
|
117
121
|
end
|
118
|
-
|
119
|
-
|
122
|
+
|
123
|
+
|
120
124
|
def execute( sql, params=[], expected_affected_rows=nil )
|
121
125
|
sql = self.format_to_sql( sql, params )
|
122
126
|
r = @connection.execute( sql );
|
123
127
|
r.each
|
124
|
-
|
128
|
+
|
125
129
|
if !expected_affected_rows.nil? and
|
126
130
|
r.affected_rows != expected_affected_rows then
|
127
131
|
raise ExpectedAffectedRowsError.new( "Expected affected rows, #{expected_affected_rows}, Actual affected rows, #{r.affected_rows}")
|
128
132
|
end
|
129
133
|
end
|
130
|
-
|
134
|
+
|
131
135
|
def insert( sql, params )
|
132
136
|
raise "Pgsql uses SEQUENCES, so possibly easier to use 2 executes"
|
133
137
|
# self.execute( sql, params )
|
134
138
|
#return @connection.last_id
|
135
139
|
end
|
136
|
-
|
140
|
+
|
137
141
|
end
|
138
|
-
|
142
|
+
|
139
143
|
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluiddb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.18
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Guy Irvine
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: A semantic layer for db interaction
|
15
14
|
email: guy@guyirvine.com
|
@@ -29,27 +28,25 @@ files:
|
|
29
28
|
- README.md
|
30
29
|
homepage: http://rubygems.org/gems/fluiddb
|
31
30
|
licenses: []
|
31
|
+
metadata: {}
|
32
32
|
post_install_message:
|
33
33
|
rdoc_options: []
|
34
34
|
require_paths:
|
35
35
|
- lib
|
36
36
|
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
37
|
requirements:
|
39
|
-
- -
|
38
|
+
- - '>='
|
40
39
|
- !ruby/object:Gem::Version
|
41
40
|
version: '0'
|
42
41
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
42
|
requirements:
|
45
|
-
- -
|
43
|
+
- - '>='
|
46
44
|
- !ruby/object:Gem::Version
|
47
45
|
version: '0'
|
48
46
|
requirements: []
|
49
47
|
rubyforge_project:
|
50
|
-
rubygems_version:
|
48
|
+
rubygems_version: 2.0.14.1
|
51
49
|
signing_key:
|
52
|
-
specification_version:
|
50
|
+
specification_version: 4
|
53
51
|
summary: FluidDB
|
54
52
|
test_files: []
|
55
|
-
has_rdoc:
|