scraperwiki 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/scraperwiki.rb +27 -0
  2. metadata +1 -1
@@ -204,4 +204,31 @@ module ScraperWiki
204
204
  end
205
205
  raise SqliteException.new(rerror)
206
206
  end
207
+
208
+ # Allows for a simplified select statement
209
+ #
210
+ # === Parameters
211
+ #
212
+ # * _sqlquery_ = A valid select statement, without the select keyword
213
+ # * _data_ = Any data provided for ? replacements in the query
214
+ # * _verbose_ = A verbosity level
215
+ #
216
+ # === Returns
217
+ # A list of hashes containing the returned data
218
+ #
219
+ # === Example
220
+ # ScraperWiki::select('* from swdata')
221
+ #
222
+ def ScraperWiki.select(sqlquery, data=nil, verbose=1)
223
+ if data != nil && sqlquery.scan(/\?/).length != 0 && data.class != Array
224
+ data = [data]
225
+ end
226
+ result = ScraperWiki.sqliteexecute("select "+sqlquery, data, verbose)
227
+ res = [ ]
228
+ for d in result["data"]
229
+ #res.push(Hash[result["keys"].zip(d)]) # post-1.8.7
230
+ res.push(Hash[*result["keys"].zip(d).flatten]) # pre-1.8.7
231
+ end
232
+ return res
233
+ end
207
234
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scraperwiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: