sqlite-ruby 2.2.2-mswin32 → 2.2.3-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -16,7 +16,7 @@ Simply do the following, after installing SQLite:
16
16
  Alternatively, you can download and install the RubyGem package for
17
17
  SQLite/Ruby (you must have RubyGems and SQLite installed, first):
18
18
 
19
- gem --remote --install sqlite
19
+ gem install --remote sqlite-ruby
20
20
 
21
21
 
22
22
  == Usage
@@ -62,25 +62,25 @@
62
62
  <ul>
63
63
  <li>How do I do a database query?
64
64
  <ul>
65
- <li><a href='#538683626'>I just want an array of the rows&#8230;</a></li>
66
- <li><a href='#538683586'>I&#8217;d like to use a block to iterate through the rows&#8230;</a></li>
67
- <li><a href='#538683546'>I need to get the column names as well as the rows&#8230;</a></li>
68
- <li><a href='#538683506'>I need the result set object itself&#8230;</a></li>
69
- <li><a href='#538683466'>I just want the first row of the result set&#8230;</a></li>
70
- <li><a href='#538683426'>I just want the first value of the first row of the result set&#8230;</a></li>
65
+ <li><a href='#538671166'>I just want an array of the rows&#8230;</a></li>
66
+ <li><a href='#538671126'>I&#8217;d like to use a block to iterate through the rows&#8230;</a></li>
67
+ <li><a href='#538671086'>I need to get the column names as well as the rows&#8230;</a></li>
68
+ <li><a href='#538671046'>I need the result set object itself&#8230;</a></li>
69
+ <li><a href='#538671006'>I just want the first row of the result set&#8230;</a></li>
70
+ <li><a href='#538670966'>I just want the first value of the first row of the result set&#8230;</a></li>
71
71
  </ul>
72
72
  </li>
73
- <li><a href='#538683356'>How do I prepare a statement for repeated execution?</a></li>
74
- <li><a href='#538683316'>How do I use placeholders in an <span class="caps">SQL</span> statement?</a></li>
75
- <li><a href='#538683276'>How do I discover metadata about a query?</a></li>
76
- <li><a href='#538683236'>I&#8217;d like the rows to be indexible by column name.</a></li>
77
- <li><a href='#538683196'>I&#8217;d like the values from a query to be the correct types, instead of String.</a></li>
78
- <li><a href='#538683156'>How do I do a <span class="caps">DDL </span>(insert, update, delete) statement?</a></li>
79
- <li><a href='#538683116'>How do I execute multiple statements in a single string?</a></li>
80
- <li><a href='#538683076'>How do I begin/end a transaction?</a></li>
73
+ <li><a href='#538670896'>How do I prepare a statement for repeated execution?</a></li>
74
+ <li><a href='#538670856'>How do I use placeholders in an <span class="caps">SQL</span> statement?</a></li>
75
+ <li><a href='#538670816'>How do I discover metadata about a query?</a></li>
76
+ <li><a href='#538670776'>I&#8217;d like the rows to be indexible by column name.</a></li>
77
+ <li><a href='#538670736'>I&#8217;d like the values from a query to be the correct types, instead of String.</a></li>
78
+ <li><a href='#538670696'>How do I do a <span class="caps">DDL </span>(insert, update, delete) statement?</a></li>
79
+ <li><a href='#538670656'>How do I execute multiple statements in a single string?</a></li>
80
+ <li><a href='#538670616'>How do I begin/end a transaction?</a></li>
81
81
  </ul>
82
82
  </div>
83
- <a name='538683626'></a>
83
+ <a name='538671166'></a>
84
84
  <div class='faq-title'>How do I do a database query? I just want an array of the rows&#8230;</div>
85
85
  <div class='faq-answer'><p>Use the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a> method. If you don&#8217;t give it a block, it will return an array of all the rows:</p>
86
86
 
@@ -91,7 +91,7 @@
91
91
  db = SQLite::<a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database</a>.new( "test.db" )
92
92
  rows = db.execute( "select * from test" )
93
93
  </pre></div>
94
- <a name='538683586'></a>
94
+ <a name='538671126'></a>
95
95
  <div class='faq-title'>How do I do a database query? I&#8217;d like to use a block to iterate through the rows&#8230;</div>
96
96
  <div class='faq-answer'><p>Use the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a> method. If you give it a block, each row of the result will be yielded to the block:</p>
97
97
 
@@ -104,7 +104,7 @@
104
104
  ...
105
105
  end
106
106
  </pre></div>
107
- <a name='538683546'></a>
107
+ <a name='538671086'></a>
108
108
  <div class='faq-title'>How do I do a database query? I need to get the column names as well as the rows&#8230;</div>
109
109
  <div class='faq-answer'><p>Use the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute2</a> method. This works just like <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a>; if you don&#8217;t give it a block, it returns an array of rows; otherwise, it will yield each row to the block. <em>However</em>, the first row returned is always an array of the column names from the query:</p>
110
110
 
@@ -113,12 +113,12 @@
113
113
  require 'sqlite'
114
114
 
115
115
  db = SQLite::<a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database</a>.new( "test.db" )
116
- columns, *rows = db.execute( "select * from test" )
116
+ columns, *rows = db.execute2( "select * from test" )
117
117
 
118
118
  # or use a block:
119
119
 
120
120
  columns = nil
121
- db.execute( "select * from test" ) do |row|
121
+ db.execute2( "select * from test" ) do |row|
122
122
  if columns.nil?
123
123
  columns = row
124
124
  else
@@ -126,7 +126,7 @@
126
126
  end
127
127
  end
128
128
  </pre></div>
129
- <a name='538683506'></a>
129
+ <a name='538671046'></a>
130
130
  <div class='faq-title'>How do I do a database query? I need the result set object itself&#8230;</div>
131
131
  <div class='faq-answer'><p>Sometimes you don&#8217;t want all the rows at once, and yet you&#8217;d like to be able to iterate through the results. For instance, you may want to pass the results to some other function (or series of functions) and have them pull rows from the results on demand. This is more effecient for very large queries.</p>
132
132
 
@@ -170,7 +170,7 @@
170
170
  end
171
171
  </pre>
172
172
  <p>In general, <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#query</a> is not a very good choice for such operations&#8230;</p></div>
173
- <a name='538683466'></a>
173
+ <a name='538671006'></a>
174
174
  <div class='faq-title'>How do I do a database query? I just want the first row of the result set&#8230;</div>
175
175
  <div class='faq-answer'><p>Easy. Just call <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#get_first_row</a>:</p>
176
176
 
@@ -179,7 +179,7 @@
179
179
  row = db.get_first_row( "select * from table" )
180
180
  </pre>
181
181
  <p>This also supports bind variables, just like <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a> and friends.</p></div>
182
- <a name='538683426'></a>
182
+ <a name='538670966'></a>
183
183
  <div class='faq-title'>How do I do a database query? I just want the first value of the first row of the result set&#8230;</div>
184
184
  <div class='faq-answer'><p>Also easy. Just call <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#get_first_value</a>:</p>
185
185
 
@@ -188,7 +188,7 @@
188
188
  count = db.get_first_value( "select count(*) from table" )
189
189
  </pre>
190
190
  <p>This also supports bind variables, just like <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a> and friends.</p></div>
191
- <a name='538683356'></a>
191
+ <a name='538670896'></a>
192
192
  <div class='faq-title'>How do I prepare a statement for repeated execution?</div>
193
193
  <div class='faq-answer'><p>If the same statement is going to be executed repeatedly, you can speed things up a bit by <em>preparing</em> the statement. You do this via the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#prepare</a> method. It returns a <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement</a> object, and you can then invoke #execute on that to get the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/ResultSet.html'>ResultSet</a>:</p>
194
194
 
@@ -203,7 +203,7 @@
203
203
  end
204
204
  </pre>
205
205
  <p>This is made more useful by the ability to bind variables to placeholders via the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement#bind_param</a> and <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement#bind_params</a> methods. (See the next <span class="caps">FAQ</span> for details.)</p></div>
206
- <a name='538683316'></a>
206
+ <a name='538670856'></a>
207
207
  <div class='faq-title'>How do I use placeholders in an <span class="caps">SQL</span> statement?</div>
208
208
  <div class='faq-answer'><p>Placeholders in an <span class="caps">SQL</span> statement take any of the following formats:</p>
209
209
  <ul>
@@ -261,7 +261,7 @@
261
261
 
262
262
  stmt.bind_params( "value", "name" =&gt; "bob" )
263
263
  </pre></div>
264
- <a name='538683276'></a>
264
+ <a name='538670816'></a>
265
265
  <div class='faq-title'>How do I discover metadata about a query?</div>
266
266
  <div class='faq-answer'><p>If you ever want to know the names or types of the columns in a result set, you can do it in several ways.</p>
267
267
 
@@ -291,7 +291,7 @@
291
291
  p stmt.columns
292
292
  p stmt.types
293
293
  </pre></div>
294
- <a name='538683236'></a>
294
+ <a name='538670776'></a>
295
295
  <div class='faq-title'>I&#8217;d like the rows to be indexible by column name.</div>
296
296
  <div class='faq-answer'><p>By default, each row from a query is returned as an Array of values. This means that you can only obtain values by their index. Sometimes, however, you would like to obtain values by their column name.</p>
297
297
 
@@ -317,7 +317,7 @@
317
317
  p row[1] == row['column2']
318
318
  end
319
319
  </pre></div>
320
- <a name='538683196'></a>
320
+ <a name='538670736'></a>
321
321
  <div class='faq-title'>I&#8217;d like the values from a query to be the correct types, instead of String.</div>
322
322
  <div class='faq-answer'><p>You can turn on &#8220;type translation&#8221; by setting <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#type_translation</a> to true:</p>
323
323
 
@@ -353,7 +353,7 @@
353
353
  obj = db.get_first_value( "select thing from objects where name='bob'" )
354
354
  p obj == h
355
355
  </pre></div>
356
- <a name='538683156'></a>
356
+ <a name='538670696'></a>
357
357
  <div class='faq-title'>How do I do a <span class="caps">DDL </span>(insert, update, delete) statement?</div>
358
358
  <div class='faq-answer'><p>You can actually do inserts, updates, and deletes in exactly the same way as selects, but in general the <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a> method will be most convenient:</p>
359
359
 
@@ -361,7 +361,7 @@
361
361
  <pre>
362
362
  db.execute( "insert into table values ( ?, ? )", *bind_vars )
363
363
  </pre></div>
364
- <a name='538683116'></a>
364
+ <a name='538670656'></a>
365
365
  <div class='faq-title'>How do I execute multiple statements in a single string?</div>
366
366
  <div class='faq-answer'><p>The standard query methods (<a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute</a>, <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute2</a>, <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#query</a>, and <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Statement.html'>Statement#execute</a>) will only execute the first statement in the string that is given to them. Thus, if you have a string with multiple <span class="caps">SQL</span> statements, each separated by a string, you can&#8217;t use those methods to execute them all at once.</p>
367
367
 
@@ -383,7 +383,7 @@
383
383
  db.execute_batch( sql )
384
384
  </pre>
385
385
  <p>Unlike the other query methods, <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#execute_batch</a> accepts no block. It will also only ever return <ins>nil</ins>. Thus, it is really only suitable for batch processing of <span class="caps">DDL</span> statements.</p></div>
386
- <a name='538683076'></a>
386
+ <a name='538670616'></a>
387
387
  <div class='faq-title'>How do I begin/end a transaction?</div>
388
388
  <div class='faq-answer'><p>Use <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#transaction</a> to start a transaction. If you give it a block, the block will be automatically committed at the end of the block, unless an exception was raised, in which case the transaction will be rolled back. (Never explicitly call <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#commit</a> or <a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database#rollback</a> inside of a transaction block&#8212;you&#8217;ll get errors when the block terminates!)</p>
389
389
 
@@ -20,7 +20,7 @@ def process_faq_list_item( faq )
20
20
  puts question_text
21
21
  process_faq_list answer
22
22
  else
23
- print "<a href='##{question.id}'>#{question_text}</a>"
23
+ print "<a href='##{question.object_id}'>#{question_text}</a>"
24
24
  end
25
25
 
26
26
  puts "</li>"
@@ -43,7 +43,7 @@ def process_faq_description( faq, path )
43
43
  title = RedCloth.new( path ).to_html.gsub( %r{</?p>}, "" )
44
44
  answer = RedCloth.new( answer || "" )
45
45
 
46
- puts "<a name='#{question.id}'></a>"
46
+ puts "<a name='#{question.object_id}'></a>"
47
47
  puts "<div class='faq-title'>#{title}</div>"
48
48
  puts "<div class='faq-answer'>#{add_api_links(answer.to_html)}</div>"
49
49
  end
@@ -40,12 +40,12 @@
40
40
  require 'sqlite'
41
41
 
42
42
  db = SQLite::Database.new( "test.db" )
43
- columns, *rows = db.execute( "select * from test" )
43
+ columns, *rows = db.execute2( "select * from test" )
44
44
 
45
45
  # or use a block:
46
46
 
47
47
  columns = nil
48
- db.execute( "select * from test" ) do |row|
48
+ db.execute2( "select * from test" ) do |row|
49
49
  if columns.nil?
50
50
  columns = row
51
51
  else
@@ -1,6 +1,6 @@
1
1
  require 'mkmf'
2
2
 
3
- dir_config( "sqlite" )
3
+ dir_config( "sqlite", "/usr/local", "/usr/local" )
4
4
  have_library( "sqlite" )
5
5
 
6
6
  if have_header( "sqlite.h" ) and have_library( "sqlite", "sqlite_open" )
@@ -36,7 +36,7 @@ module SQLite
36
36
 
37
37
  MAJOR = 2
38
38
  MINOR = 2
39
- TINY = 2
39
+ TINY = 3
40
40
 
41
41
  STRING = [ MAJOR, MINOR, TINY ].join( "." )
42
42
 
Binary file
@@ -0,0 +1,58 @@
1
+ create table A
2
+ (
3
+ name VARCHAR(60),
4
+ age INTEGER,
5
+ birth DATE
6
+ );
7
+
8
+ create table B
9
+ (
10
+ id INTEGER PRIMARY KEY,
11
+ name VARCHAR(60)
12
+ );
13
+
14
+ create index B_idx on B ( name );
15
+
16
+ create table C
17
+ (
18
+ d1 DATE,
19
+ d2 DATETIME,
20
+ d3 TIME,
21
+ r1 DECIMAL,
22
+ r2 FLOAT,
23
+ r3 NUMERIC,
24
+ r4 DOUBLE,
25
+ r5 REAL,
26
+ r6 DEC,
27
+ r7 FIXED,
28
+ i1 INTEGER,
29
+ i2 SMALLINT,
30
+ i3 MEDIUMINT,
31
+ i4 INT,
32
+ i5 BIGINT,
33
+ b1 BIT,
34
+ b2 BOOL,
35
+ b3 BOOLEAN,
36
+ t1 TIMESTAMP,
37
+ t2 TINYINT(1),
38
+ t3 TINYINT(4),
39
+ s1 STRING,
40
+ s2 VARCHAR(15),
41
+ s3 CHAR(15),
42
+ s4 VARCHAR2(15),
43
+ m1 OBJECT,
44
+ n1 STRING,
45
+ n2 DATE,
46
+ n3 BOOLEAN
47
+ );
48
+
49
+ create table D
50
+ (
51
+ b_id INTEGER REFERENCES B ( id )
52
+ );
53
+
54
+ create table E
55
+ (
56
+ name VARCHAR(20) NOT NULL,
57
+ thing OBJECT
58
+ );
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.1
2
+ rubygems_version: 0.8.4
3
3
  specification_version: 1
4
4
  name: sqlite-ruby
5
5
  version: !ruby/object:Gem::Version
6
- version: 2.2.2
7
- date: 2004-11-15
6
+ version: 2.2.3
7
+ date: 2005-01-30
8
8
  summary: SQLite/Ruby is a module to allow Ruby scripts to interface with a SQLite database.
9
9
  require_paths:
10
10
  - lib
11
- author: Jamis Buck
12
11
  email: jgb3@email.byu.edu
13
12
  homepage: http://sqlite-ruby.rubyforge.org
14
13
  rubyforge_project:
@@ -25,6 +24,8 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
24
  version: 1.8.0
26
25
  version:
27
26
  platform: mswin32
27
+ authors:
28
+ - Jamis Buck
28
29
  files:
29
30
  - doc/faq
30
31
  - doc/faq/faq.html
@@ -43,6 +44,7 @@ files:
43
44
  - lib/sqlite/version.rb
44
45
  - lib/sqlite/pragmas.rb
45
46
  - test/db
47
+ - test/sql
46
48
  - test/tc_parsed_statement.rb
47
49
  - test/tc_api_core.rb
48
50
  - test/tests.rb
@@ -52,6 +54,7 @@ files:
52
54
  - test/tc_type_translation.rb
53
55
  - test/tc_database.rb
54
56
  - test/db/fixtures.sql
57
+ - test/sql/fixtures.sql
55
58
  - README
56
59
  test_files:
57
60
  - test/tests.rb