sqlite-ruby 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -62,25 +62,25 @@
62
62
  <ul>
63
63
  <li>How do I do a database query?
64
64
  <ul>
65
- <li><a href='#538789240'>I just want an array of the rows&#8230;</a></li>
66
- <li><a href='#538789200'>I&#8217;d like to use a block to iterate through the rows&#8230;</a></li>
67
- <li><a href='#538789150'>I need to get the column names as well as the rows&#8230;</a></li>
68
- <li><a href='#538789110'>I need the result set object itself&#8230;</a></li>
69
- <li><a href='#538789070'>I just want the first row of the result set&#8230;</a></li>
70
- <li><a href='#538789030'>I just want the first value of the first row of the result set&#8230;</a></li>
65
+ <li><a href='#538732450'>I just want an array of the rows&#8230;</a></li>
66
+ <li><a href='#538732410'>I&#8217;d like to use a block to iterate through the rows&#8230;</a></li>
67
+ <li><a href='#538732370'>I need to get the column names as well as the rows&#8230;</a></li>
68
+ <li><a href='#538732330'>I need the result set object itself&#8230;</a></li>
69
+ <li><a href='#538732290'>I just want the first row of the result set&#8230;</a></li>
70
+ <li><a href='#538732250'>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='#538788960'>How do I prepare a statement for repeated execution?</a></li>
74
- <li><a href='#538788920'>How do I use placeholders in an <span class="caps">SQL</span> statement?</a></li>
75
- <li><a href='#538788880'>How do I discover metadata about a query?</a></li>
76
- <li><a href='#538788840'>I&#8217;d like the rows to be indexible by column name.</a></li>
77
- <li><a href='#538788800'>I&#8217;d like the values from a query to be the correct types, instead of String.</a></li>
78
- <li><a href='#538788760'>How do I do a <span class="caps">DDL </span>(insert, update, delete) statement?</a></li>
79
- <li><a href='#538788720'>How do I execute multiple statements in a single string?</a></li>
80
- <li><a href='#538788680'>How do I begin/end a transaction?</a></li>
73
+ <li><a href='#538732180'>How do I prepare a statement for repeated execution?</a></li>
74
+ <li><a href='#538732140'>How do I use placeholders in an <span class="caps">SQL</span> statement?</a></li>
75
+ <li><a href='#538732100'>How do I discover metadata about a query?</a></li>
76
+ <li><a href='#538732060'>I&#8217;d like the rows to be indexible by column name.</a></li>
77
+ <li><a href='#538732020'>I&#8217;d like the values from a query to be the correct types, instead of String.</a></li>
78
+ <li><a href='#538731980'>How do I do a <span class="caps">DDL </span>(insert, update, delete) statement?</a></li>
79
+ <li><a href='#538731940'>How do I execute multiple statements in a single string?</a></li>
80
+ <li><a href='#538731900'>How do I begin/end a transaction?</a></li>
81
81
  </ul>
82
82
  </div>
83
- <a name='538789240'></a>
83
+ <a name='538732450'></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
 
@@ -90,7 +90,7 @@
90
90
  db = SQLite::<a href='http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html'>Database</a>.new( "test.db" )
91
91
  rows = db.execute( "select * from test" )
92
92
  </pre></div>
93
- <a name='538789200'></a>
93
+ <a name='538732410'></a>
94
94
  <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>
95
95
  <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>
96
96
 
@@ -102,7 +102,7 @@
102
102
  ...
103
103
  end
104
104
  </pre></div>
105
- <a name='538789150'></a>
105
+ <a name='538732370'></a>
106
106
  <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>
107
107
  <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>
108
108
 
@@ -123,7 +123,7 @@
123
123
  end
124
124
  end
125
125
  </pre></div>
126
- <a name='538789110'></a>
126
+ <a name='538732330'></a>
127
127
  <div class='faq-title'>How do I do a database query? I need the result set object itself&#8230;</div>
128
128
  <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>
129
129
 
@@ -167,7 +167,7 @@
167
167
  </pre>
168
168
 
169
169
  <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>
170
- <a name='538789070'></a>
170
+ <a name='538732290'></a>
171
171
  <div class='faq-title'>How do I do a database query? I just want the first row of the result set&#8230;</div>
172
172
  <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>
173
173
 
@@ -176,7 +176,7 @@
176
176
  </pre>
177
177
 
178
178
  <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>
179
- <a name='538789030'></a>
179
+ <a name='538732250'></a>
180
180
  <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>
181
181
  <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>
182
182
 
@@ -185,7 +185,7 @@
185
185
  </pre>
186
186
 
187
187
  <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>
188
- <a name='538788960'></a>
188
+ <a name='538732180'></a>
189
189
  <div class='faq-title'>How do I prepare a statement for repeated execution?</div>
190
190
  <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>
191
191
 
@@ -200,7 +200,7 @@
200
200
  </pre>
201
201
 
202
202
  <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>
203
- <a name='538788920'></a>
203
+ <a name='538732140'></a>
204
204
  <div class='faq-title'>How do I use placeholders in an <span class="caps">SQL</span> statement?</div>
205
205
  <div class='faq-answer'><p>Placeholders in an <span class="caps">SQL</span> statement take any of the following formats:</p>
206
206
 
@@ -258,7 +258,7 @@
258
258
 
259
259
  stmt.bind_params( "value", "name" =&gt; "bob" )
260
260
  </pre></div>
261
- <a name='538788880'></a>
261
+ <a name='538732100'></a>
262
262
  <div class='faq-title'>How do I discover metadata about a query?</div>
263
263
  <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>
264
264
 
@@ -287,7 +287,7 @@
287
287
  p stmt.columns
288
288
  p stmt.types
289
289
  </pre></div>
290
- <a name='538788840'></a>
290
+ <a name='538732060'></a>
291
291
  <div class='faq-title'>I&#8217;d like the rows to be indexible by column name.</div>
292
292
  <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>
293
293
 
@@ -312,7 +312,7 @@
312
312
  p row[1] == row['column2']
313
313
  end
314
314
  </pre></div>
315
- <a name='538788800'></a>
315
+ <a name='538732020'></a>
316
316
  <div class='faq-title'>I&#8217;d like the values from a query to be the correct types, instead of String.</div>
317
317
  <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>
318
318
 
@@ -347,14 +347,14 @@
347
347
  obj = db.get_first_value( "select thing from objects where name='bob'" )
348
348
  p obj == h
349
349
  </pre></div>
350
- <a name='538788760'></a>
350
+ <a name='538731980'></a>
351
351
  <div class='faq-title'>How do I do a <span class="caps">DDL </span>(insert, update, delete) statement?</div>
352
352
  <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>
353
353
 
354
354
  <pre>
355
355
  db.execute( "insert into table values ( ?, ? )", *bind_vars )
356
356
  </pre></div>
357
- <a name='538788720'></a>
357
+ <a name='538731940'></a>
358
358
  <div class='faq-title'>How do I execute multiple statements in a single string?</div>
359
359
  <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>
360
360
 
@@ -376,7 +376,7 @@
376
376
  </pre>
377
377
 
378
378
  <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>
379
- <a name='538788680'></a>
379
+ <a name='538731900'></a>
380
380
  <div class='faq-title'>How do I begin/end a transaction?</div>
381
381
  <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>
382
382
 
@@ -1269,6 +1269,8 @@ static_protected_function_callback( VALUE args )
1269
1269
  proc_args = rb_ary_entry( args, 1 );
1270
1270
 
1271
1271
  rb_apply( proc, idCall, proc_args );
1272
+
1273
+ return Qnil;
1272
1274
  }
1273
1275
 
1274
1276
  static void
@@ -35,8 +35,8 @@ module SQLite
35
35
  module Version
36
36
 
37
37
  MAJOR = 2
38
- MINOR = 0
39
- TINY = 3
38
+ MINOR = 1
39
+ TINY = 0
40
40
 
41
41
  STRING = [ MAJOR, MINOR, TINY ].join( "." )
42
42
 
metadata CHANGED
@@ -3,9 +3,9 @@ rubygems_version: 0.8.1
3
3
  specification_version: 1
4
4
  name: sqlite-ruby
5
5
  version: !ruby/object:Gem::Version
6
- version: 2.0.3
7
- date: 2004-09-20
8
- summary: "SQLite/Ruby is a module to allow Ruby scripts to interface with a SQLite database. VERSIONS >=2.0.0 ARE BETA RELEASES. THEY ARE INTENDED FOR TESTING ONLY, AND SHOULD NOT BE CONSIDERED PRODUCTION-WORTHY YET."
6
+ version: 2.1.0
7
+ date: 2004-09-27
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
11
  author: Jamis Buck