rails-dbi 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +3694 -0
- data/LICENSE +25 -0
- data/README +271 -0
- data/bin/dbi +518 -0
- data/bin/test_broken_dbi +37 -0
- data/build/Rakefile.dbi.rb +60 -0
- data/examples/test1.pl +39 -0
- data/examples/test1.rb +20 -0
- data/examples/xmltest.rb +8 -0
- data/lib/dbi/base_classes/database.rb +135 -0
- data/lib/dbi/base_classes/driver.rb +47 -0
- data/lib/dbi/base_classes/statement.rb +171 -0
- data/lib/dbi/base_classes.rb +12 -0
- data/lib/dbi/binary.rb +25 -0
- data/lib/dbi/columninfo.rb +107 -0
- data/lib/dbi/exceptions.rb +65 -0
- data/lib/dbi/handles/database.rb +241 -0
- data/lib/dbi/handles/driver.rb +60 -0
- data/lib/dbi/handles/statement.rb +408 -0
- data/lib/dbi/handles.rb +49 -0
- data/lib/dbi/row.rb +270 -0
- data/lib/dbi/sql/preparedstatement.rb +115 -0
- data/lib/dbi/sql.rb +22 -0
- data/lib/dbi/sql_type_constants.rb +75 -0
- data/lib/dbi/trace.rb +91 -0
- data/lib/dbi/types.rb +218 -0
- data/lib/dbi/typeutil.rb +109 -0
- data/lib/dbi/utils/date.rb +59 -0
- data/lib/dbi/utils/tableformatter.rb +112 -0
- data/lib/dbi/utils/time.rb +52 -0
- data/lib/dbi/utils/timestamp.rb +96 -0
- data/lib/dbi/utils/xmlformatter.rb +73 -0
- data/lib/dbi/utils.rb +60 -0
- data/lib/dbi.rb +337 -0
- data/test/dbi/tc_columninfo.rb +94 -0
- data/test/dbi/tc_date.rb +88 -0
- data/test/dbi/tc_dbi.rb +184 -0
- data/test/dbi/tc_row.rb +256 -0
- data/test/dbi/tc_sqlbind.rb +168 -0
- data/test/dbi/tc_statementhandle.rb +29 -0
- data/test/dbi/tc_time.rb +77 -0
- data/test/dbi/tc_timestamp.rb +142 -0
- data/test/dbi/tc_types.rb +268 -0
- data/test/ts_dbi.rb +15 -0
- metadata +132 -0
data/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
(C) 2008 Erik Hollensbe <erik@hollensbe.org>. All rights reserved.
|
2
|
+
|
3
|
+
Please see "README" for earlier copyrights.
|
4
|
+
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
6
|
+
modification, are permitted provided that the following conditions
|
7
|
+
are met:
|
8
|
+
1. Redistributions of source code must retain the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer in the
|
12
|
+
documentation and/or other materials provided with the distribution.
|
13
|
+
3. The name of the author may not be used to endorse or promote products
|
14
|
+
derived from this software without specific prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
17
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
18
|
+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
19
|
+
THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
20
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
21
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
22
|
+
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
23
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
24
|
+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
25
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README
ADDED
@@ -0,0 +1,271 @@
|
|
1
|
+
= Description
|
2
|
+
The DBI package is a vendor independent interface for accessing databases.
|
3
|
+
It is similar, but not identical to, Perl's DBI module.
|
4
|
+
|
5
|
+
= Synopsis
|
6
|
+
|
7
|
+
require 'dbi'
|
8
|
+
|
9
|
+
# Connect to a database, old style
|
10
|
+
dbh = DBI.connect('DBI:Mysql:test', 'testuser', 'testpwd')
|
11
|
+
|
12
|
+
# Insert some rows, use placeholders
|
13
|
+
1.upto(13) do |i|
|
14
|
+
sql = "insert into simple01 (SongName, SongLength_s) VALUES (?, ?)"
|
15
|
+
dbh.do(sql, "Song #{i}", "#{i*10}")
|
16
|
+
end
|
17
|
+
|
18
|
+
# Select all rows from simple01
|
19
|
+
sth = dbh.prepare('select * from simple01')
|
20
|
+
sth.execute
|
21
|
+
|
22
|
+
# Print out each row
|
23
|
+
while row=sth.fetch do
|
24
|
+
p row
|
25
|
+
end
|
26
|
+
|
27
|
+
# Close the statement handle when done
|
28
|
+
sth.finish
|
29
|
+
|
30
|
+
# Don't prepare, just do it!
|
31
|
+
dbh.do('delete from simple01 where internal_id > 10')
|
32
|
+
|
33
|
+
# And finally, disconnect
|
34
|
+
dbh.disconnect
|
35
|
+
|
36
|
+
# Same example, but a little more Ruby-ish
|
37
|
+
DBI.connect('DBI:Mysql:test', 'testuser', 'testpwd') do | dbh |
|
38
|
+
|
39
|
+
sql = "insert into simple01 (SongName, SongLength_s) VALUES (?, ?)"
|
40
|
+
|
41
|
+
dbh.prepare(sql) do | sth |
|
42
|
+
1.upto(13) { |i| sth.execute("Song #{i}", "#{i*10}") }
|
43
|
+
end
|
44
|
+
|
45
|
+
dbh.select_all('select * from simple01') do | row |
|
46
|
+
p row
|
47
|
+
end
|
48
|
+
|
49
|
+
dbh.do('delete from simple01 where internal_id > 10')
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
= Prerequisites
|
54
|
+
Ruby 1.8.6 or later is the test target, however you may have success with
|
55
|
+
earlier 1.8.x versions of Ruby.
|
56
|
+
|
57
|
+
= RubyForge Project
|
58
|
+
General information: http://ruby-dbi.rubyforge.org
|
59
|
+
Project information: http://rubyforge.org/projects/ruby-dbi/
|
60
|
+
Downloads: http://rubyforge.org/frs/?group_id=234
|
61
|
+
|
62
|
+
= Installation
|
63
|
+
There are many database drivers (DBDs) available. You only need to install
|
64
|
+
the DBDs for the database software that you will be using.
|
65
|
+
|
66
|
+
== Gem setup:
|
67
|
+
|
68
|
+
gem install dbi
|
69
|
+
# One or more of:
|
70
|
+
gem install dbd-mysql
|
71
|
+
gem install dbd-pg
|
72
|
+
gem install dbd-sqlite3
|
73
|
+
gem install dbd-sqlite
|
74
|
+
|
75
|
+
== Without rubygems:
|
76
|
+
|
77
|
+
ruby setup.rb config
|
78
|
+
ruby setup.rb setup
|
79
|
+
ruby setup.rb install
|
80
|
+
|
81
|
+
== The bleeding edge:
|
82
|
+
|
83
|
+
git clone git://hollensbe.org/git/ruby-dbi.git
|
84
|
+
git checkout -b development origin/development
|
85
|
+
|
86
|
+
Also available at
|
87
|
+
|
88
|
+
git clone git://github.com/erikh/ruby-dbi.git
|
89
|
+
|
90
|
+
= Available Database Drivers (DBDs)
|
91
|
+
|
92
|
+
== DBD::MySQL
|
93
|
+
MySQL
|
94
|
+
Depends on the mysql-ruby package from http://www.tmtm.org/mysql or
|
95
|
+
available from the RAA.
|
96
|
+
|
97
|
+
== DBD::ODBC
|
98
|
+
ODBC
|
99
|
+
Depends on the ruby-odbc package (0.5 or later, 0.9.3 or later recommended) at
|
100
|
+
http://www.ch-werner.de/rubyodbc or available from the RAA. Works together
|
101
|
+
with unix-odbc.
|
102
|
+
|
103
|
+
== DBD::OCI8
|
104
|
+
OCI8 (Oracle)
|
105
|
+
Depends on the the ruby-oci8 package, available on the RAA and RubyForge.
|
106
|
+
|
107
|
+
== DBD::Pg
|
108
|
+
PostgreSQL
|
109
|
+
Depends on the pg package, available on RubyForge.
|
110
|
+
|
111
|
+
== DBD::SQLite
|
112
|
+
SQLite (versions 2.x and earlier)
|
113
|
+
Depends on the sqlite-ruby package, available on rubyforge.
|
114
|
+
|
115
|
+
== DBD::SQLite3
|
116
|
+
SQLite 3.x
|
117
|
+
Depends on the sqlite3-ruby package, available on rubyforge.
|
118
|
+
|
119
|
+
= Additional Documentation
|
120
|
+
See the directories doc/* for DBI and DBD specific information.
|
121
|
+
The DBI specification is at doc/DBI_SPEC.rdoc.
|
122
|
+
The DBD specification is at doc/DBD_SPEC.rdoc.
|
123
|
+
|
124
|
+
= Articles
|
125
|
+
== Tutorial: Using the Ruby DBI Module
|
126
|
+
http://www.kitebird.com/articles/ruby-dbi.html
|
127
|
+
|
128
|
+
= Applications
|
129
|
+
== dbi
|
130
|
+
The SQL command line interpreter dbi is available in directory
|
131
|
+
bin/. It gets installed by default.
|
132
|
+
|
133
|
+
= License
|
134
|
+
|
135
|
+
Copyright (c) 2008 Erik Hollensbe
|
136
|
+
|
137
|
+
Copyright (c) 2005-2006 Kirk Haines, Francis Hwang, Patrick May and Daniel
|
138
|
+
Berger.
|
139
|
+
|
140
|
+
Copyright (c) 2001, 2002, 2003, 2004 Michael Neumann <mneumann@ntecs.de>
|
141
|
+
and others (see the beginning of each file for copyright holder information).
|
142
|
+
|
143
|
+
All rights reserved.
|
144
|
+
|
145
|
+
Redistribution and use in source and binary forms, with or without
|
146
|
+
modification, are permitted provided that the following conditions are met:
|
147
|
+
|
148
|
+
1. Redistributions of source code must retain the above copyright notice,
|
149
|
+
this list of conditions and the following disclaimer.
|
150
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
151
|
+
this list of conditions and the following disclaimer in the documentation
|
152
|
+
and/or other materials provided with the distribution.
|
153
|
+
3. The name of the author may not be used to endorse or promote products
|
154
|
+
derived from this software without specific prior written permission.
|
155
|
+
|
156
|
+
THIS SOFTWARE IS PROVIDED 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
157
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
158
|
+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
159
|
+
THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
160
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
161
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
162
|
+
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
163
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
164
|
+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
165
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
166
|
+
|
167
|
+
This is the BSD license which is less restrictive than GNU's GPL
|
168
|
+
(General Public License).
|
169
|
+
|
170
|
+
= Contributors
|
171
|
+
|
172
|
+
Pistos
|
173
|
+
Too much to specify. Infinite patience and help.
|
174
|
+
|
175
|
+
Christopher Maujean
|
176
|
+
Lots of initial help when reviving the project.
|
177
|
+
|
178
|
+
Jun Mukai <mukai@jmuk.org>
|
179
|
+
Contributed initial SQLite3 DBD.
|
180
|
+
|
181
|
+
John J. Fox IV
|
182
|
+
Lots of help testing on multiple platforms.
|
183
|
+
|
184
|
+
Kirk Haines
|
185
|
+
One of the authors of the rewrite effort (January 2006).
|
186
|
+
|
187
|
+
Francis Hwang
|
188
|
+
One of the authors of the rewrite effort (January 2006).
|
189
|
+
|
190
|
+
Patrick May
|
191
|
+
One of the authors of the rewrite effort (January 2006).
|
192
|
+
|
193
|
+
Daniel Berger
|
194
|
+
One of the authors of the rewrite effort (January 2006).
|
195
|
+
|
196
|
+
Michael Neumann
|
197
|
+
Original author of Ruby/DBI; wrote the DBI and most of the DBDs.
|
198
|
+
|
199
|
+
Rainer Perl
|
200
|
+
Author of Ruby/DBI 0.0.4 from which many good ideas were taken.
|
201
|
+
|
202
|
+
Jim Weirich
|
203
|
+
Original author of DBD::Pg. Wrote additional code (e.g. sql.rb,
|
204
|
+
testcases). Gave many helpful hints and comments.
|
205
|
+
|
206
|
+
Eli Green
|
207
|
+
Implemented DatabaseHandle#columns for Mysql and Pg.
|
208
|
+
|
209
|
+
Masatoshi SEKI
|
210
|
+
For his version of module BasicQuote in sql.rb.
|
211
|
+
|
212
|
+
John Gorman
|
213
|
+
For his case insensitive load_driver patch and parameter parser.
|
214
|
+
|
215
|
+
David Muse
|
216
|
+
For testing the DBD::SQLRelay and for his initial DBD.
|
217
|
+
|
218
|
+
Jim Menard
|
219
|
+
Extended DBD::Oracle for method columns.
|
220
|
+
|
221
|
+
Joseph McDonald
|
222
|
+
Fixed bug in DBD::Pg (default values in method columns).
|
223
|
+
|
224
|
+
Norbert Gawor
|
225
|
+
Fixed bug in DBD::ODBC (method columns) and proxyserver.
|
226
|
+
|
227
|
+
James F. Hranicky
|
228
|
+
Patch for DBD::Pg (cache PGResult#result in Tuples) which increased
|
229
|
+
performance by a factor around 100.
|
230
|
+
|
231
|
+
Stephen Davies
|
232
|
+
Added method Statement#fetch_scroll for DBD::Pg.
|
233
|
+
|
234
|
+
Dave Thomas
|
235
|
+
Several enhancements.
|
236
|
+
|
237
|
+
Brad Hilton
|
238
|
+
Column coercing patch for DBD::Mysql.
|
239
|
+
|
240
|
+
Sean Chittenden
|
241
|
+
Originally a co-owner of the project. Submitted several patches
|
242
|
+
and helped with lots of comments.
|
243
|
+
|
244
|
+
MoonWolf
|
245
|
+
Provided the quote/escape_byte patch for DBD::Pg, DBD::SQLite patch and
|
246
|
+
Database#columns implementation. Further patches.
|
247
|
+
|
248
|
+
Paul DuBois
|
249
|
+
Fixed typos and formatting. Maintains DBD::Mysql.
|
250
|
+
|
251
|
+
Tim Bates
|
252
|
+
Bug fixes for Mysql and DBI.
|
253
|
+
|
254
|
+
Brian Candler
|
255
|
+
Zero-padding date/time/timestamps fix.
|
256
|
+
|
257
|
+
Florian G. Pflug
|
258
|
+
Discussion and helpful comments/benchmarks about DBD::Pg async_exec vs.
|
259
|
+
exec.
|
260
|
+
|
261
|
+
Oliver M. Bolzer
|
262
|
+
Patches to support Postgres arrays for DBD::Pg.
|
263
|
+
|
264
|
+
Stephen R. Veit
|
265
|
+
ruby-db2 and DBD::DB2 enhancements.
|
266
|
+
|
267
|
+
Dennis Vshivkov
|
268
|
+
DBD::Pg patches
|
269
|
+
|
270
|
+
Cail Borrell from frontbase.com
|
271
|
+
For the Frontbase DBD and C interface.
|