kemen-ruby-odbc 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/test/00connect.rb ADDED
@@ -0,0 +1 @@
1
+ $c = ODBC.connect($dsn, $uid, $pwd)
@@ -0,0 +1 @@
1
+ $c.run("create table test (id int not null, str varchar(32) not null)")
data/test/20insert.rb ADDED
@@ -0,0 +1,6 @@
1
+ $q = $c.run("insert into test (id, str) values (1, 'foo')")
2
+ $q.run("insert into test (id, str) values (2, 'bar')")
3
+
4
+ $p = $c.proc("insert into test (id, str) values (?, ?)") {}
5
+ $p.call(3, "FOO")
6
+ $p[4, "BAR"]
data/test/30select.rb ADDED
@@ -0,0 +1,69 @@
1
+ $q = $c.prepare("select id,str from test")
2
+
3
+ if $q.column(0).name.upcase != "ID" then raise "fetch failed" end
4
+ if $q.column(1).name.upcase != "STR" then raise "fetch failed" end
5
+
6
+ $q.execute
7
+ if $q.fetch != [1, "foo"] then raise "fetch: failed" end
8
+ if $q.fetch != [2, "bar"] then raise "fetch: failed" end
9
+ if $q.fetch != [3, "FOO"] then raise "fetch: failed" end
10
+ if $q.fetch != [4, "BAR"] then raise "fetch: failed" end
11
+ if $q.fetch != nil then raise "fetch: failed" end
12
+ $q.close
13
+
14
+ if $q.execute.entries != [[1, "foo"], [2, "bar"], [3, "FOO"], [4, "BAR"]] then
15
+ raise "fetch: failed"
16
+ end
17
+ $q.close
18
+
19
+ if $q.execute.fetch_all != [[1, "foo"], [2, "bar"], [3, "FOO"], [4, "BAR"]] then
20
+ raise "fetch: failed"
21
+ end
22
+ $q.close
23
+
24
+ $q.execute
25
+ if $q.fetch_many(2) != [[1, "foo"], [2, "bar"]] then raise "fetch: failed" end
26
+ if $q.fetch_many(3) != [[3, "FOO"], [4, "BAR"]] then raise "fetch: failed" end
27
+ if $q.fetch_many(99) != nil then raise "fetch: failed" end
28
+ $q.close
29
+
30
+ a = []
31
+ $q.execute {|r| a=r.entries}
32
+ if a.size != 4 then raise "fetch: failed" end
33
+ $q.close
34
+
35
+ a = []
36
+ $q.execute.each {|r| a.push(r)}
37
+ if a.size != 4 then raise "fetch: failed" end
38
+ $q.close
39
+
40
+ a = []
41
+ $q.execute.each_hash {|r| a.push(r)}
42
+ if a.size != 4 then raise "fetch: failed" end
43
+ $q.close
44
+
45
+ a = []
46
+ $q.execute.each_hash(true) {|r| a.push(r)}
47
+ if a.size != 4 then raise "fetch: failed" end
48
+ $q.close
49
+
50
+ a = []
51
+ $q.execute.each_hash(:key=>:Symbol) {|r| a.push(r)}
52
+ if a.size != 4 then raise "fetch: failed" end
53
+ $q.close
54
+
55
+ a = []
56
+ $q.execute.each_hash(:key=>:Symbol,:table_names=>true) {|r| a.push(r)}
57
+ if a.size != 4 then raise "fetch: failed" end
58
+ $q.close
59
+
60
+ a = []
61
+ $q.execute.each_hash(:key=>:String,:table_names=>false) {|r| a.push(r)}
62
+ if a.size != 4 then raise "fetch: failed" end
63
+ $q.close
64
+
65
+ a = []
66
+ $q.execute.each_hash(:key=>:Fixnum,:table_names=>false) {|r| a.push(r)}
67
+ if a.size != 4 then raise "fetch: failed" end
68
+ $q.close
69
+
data/test/40update.rb ADDED
@@ -0,0 +1,4 @@
1
+ $q = $c.run("update test set id=0, str='hoge'")
2
+ if $q.nrows != 4 then
3
+ $stderr.print "update row count: expected 4, got ", $q.nrows, "\n"
4
+ end
@@ -0,0 +1,3 @@
1
+ # drop all statements, otherwise table might be locked for drop.
2
+ $c.drop_all
3
+ $c.do("drop table test")
data/test/70close.rb ADDED
@@ -0,0 +1 @@
1
+ $c.disconnect
data/test/test.rb ADDED
@@ -0,0 +1,32 @@
1
+ # $Id: test.rb,v 1.7 2010/02/18 12:30:43 chw Exp chw $
2
+ #
3
+ # Execute in ruby-odbc top directory.
4
+ #
5
+ # ruby test.rb "mysql-DSN" "mysql-user" "mysql-password"
6
+ #
7
+ # Test creates and deletes table "test" in that DSN.
8
+
9
+ require 'odbc'
10
+
11
+ $dsn = ARGV.shift
12
+ $uid = ARGV.shift
13
+ $pwd = ARGV.shift
14
+
15
+ begin
16
+ Dir.glob("test/[0-9]*.rb").sort.each do |f|
17
+ f =~ /^test\/\d+(.*)\.rb$/
18
+ print $1 + "."*(20-$1.length)
19
+ $stdout.flush
20
+ load f
21
+ print "ok\n"
22
+ end
23
+ ensure
24
+ begin
25
+ $c.drop_all unless $c.class != ODBC::Database
26
+ rescue
27
+ end
28
+ begin
29
+ ODBC.connect($dsn, $uid, $pwd).do("drop table test")
30
+ rescue
31
+ end
32
+ end
data/test/utf8/test.rb ADDED
@@ -0,0 +1,32 @@
1
+ # $Id: test.rb,v 1.3 2010/02/18 12:30:43 chw Exp chw $
2
+ #
3
+ # Execute in ruby-odbc utf8 directory.
4
+ #
5
+ # ruby test.rb "mysql-DSN" "mysql-user" "mysql-password"
6
+ #
7
+ # Test creates and deletes table "test" in that DSN.
8
+
9
+ require 'odbc_utf8'
10
+
11
+ $dsn = ARGV.shift
12
+ $uid = ARGV.shift
13
+ $pwd = ARGV.shift
14
+
15
+ begin
16
+ Dir.glob("../test/[0-9]*.rb").sort.each do |f|
17
+ f =~ /^..\/test\/\d+(.*)\.rb$/
18
+ print $1 + "."*(20-$1.length)
19
+ $stdout.flush
20
+ load f
21
+ print "ok\n"
22
+ end
23
+ ensure
24
+ begin
25
+ $c.drop_all unless $c.class != ODBC::Database
26
+ rescue
27
+ end
28
+ begin
29
+ ODBC.connect($dsn, $uid, $pwd).do("drop table test")
30
+ rescue
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kemen-ruby-odbc
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ version: "0.1"
9
+ platform: ruby
10
+ authors:
11
+ - Christian Werner
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2011-02-02 00:00:00 +01:00
17
+ default_executable:
18
+ dependencies: []
19
+
20
+ description:
21
+ email: chw @nospam@ ch-werner.de
22
+ executables: []
23
+
24
+ extensions:
25
+ - ext/extconf.rb
26
+ - ext/utf8/extconf.rb
27
+ extra_rdoc_files:
28
+ - README
29
+ - COPYING
30
+ - ChangeLog
31
+ - GPL
32
+ - doc/odbc.html
33
+ files:
34
+ - lib/cqgen.rb
35
+ - GPL
36
+ - ext/utf8/extconf.rb
37
+ - ext/utf8/odbc.c
38
+ - ext/utf8/init.c
39
+ - ext/extconf.rb
40
+ - ext/odbc.c
41
+ - ext/init.c
42
+ - MANIFEST
43
+ - kemen-ruby-odbc.gemspec
44
+ - doc/odbc.html
45
+ - COPYING
46
+ - ChangeLog
47
+ - kemen-ruby-odbc-0.1.gem
48
+ - test/utf8/test.rb
49
+ - test/20insert.rb
50
+ - test/00connect.rb
51
+ - test/50drop_table.rb
52
+ - test/30select.rb
53
+ - test/70close.rb
54
+ - test/test.rb
55
+ - test/40update.rb
56
+ - test/10create_table.rb
57
+ - README
58
+ has_rdoc: true
59
+ homepage: http://www.ch-werner.de/rubyodbc
60
+ licenses: []
61
+
62
+ post_install_message:
63
+ rdoc_options: []
64
+
65
+ require_paths:
66
+ - lib
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project:
87
+ rubygems_version: 1.3.7
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Fork of ruby-odbc-0.99994 - ODBC binding for Ruby
91
+ test_files: []
92
+