motivation:

overview:

requirements/environment:

code: [sourcecode lang=“ruby”] class YqlStorage def use(settings={}) @settings = settings return self end def get(key)

response = yql( %{ use ‘http://{your domain}/kv.xml’ as kv; select * from kv where key = ‘%s’ and select = ‘%s’ } % [ key, @settings[:select] ] )

if response[’error’] raise ’error: %s ’ % response[’error’][‘description’] elsif !response[‘query’][‘results’] return nil end

return response[‘query’][‘results’][‘result’] end

def set(key, val)

response = yql( %{ insert into kv (key, val) values (’%s’, ‘%s’) } % [ key, val ], { ’env’ => ‘http://{your domain}/kv.env’ } )

if response[’error’] raise ‘YQL error: %s ’ % response[’error’][‘description’] end

return response end end [/sourcecode]

usage:

  1. Save the code below into a file
  2. Edit the file to change all occurrences of ‘{your domain}’ to your domain
  3. Use (ha!) the YQL storage addresses defined in the key/val table setup for the use() settings
  4. here’s some example code [sourcecode lang=“ruby”] store = YqlStorage.new.use( {

    get these from YQL: http://developer.yahoo.com/yql/console/#h=desc%20yql.storage.admin

    :execute => ‘store://h5Y4iRockdwzZdEHvGbBkCe’, :select => ‘store://deGTN05aNePaper04EOL30W’, :update => ‘store://qG4Scissors8917SHDjv88Wb’ } ) store.set( ‘foo’, ‘bar’ ) p store.get( ‘foo’ ) [/sourcecode]

Please let me know if you’ve got any suggestions/questions.

And now, to lighten the mood, here’s a picture of a squirrel yawning: Squirrel yawning Photo credit: _temaki_