Skip to content
This repository was archived by the owner on Nov 27, 2019. It is now read-only.
This repository was archived by the owner on Nov 27, 2019. It is now read-only.

ScraperWiki.select or ScraperWiki.save_sqlite first? #24

@GildedHonour

Description

@GildedHonour

If I do this

  items.each do |item|
    if ScraperWiki.select("* from swdata where ....).empty? 
       ScraperWiki.save_sqlite(["key123"], item)
     else
       puts "Skipping " + item["key123"]
     end
 end

and the db (or rather table) doesn't exist then I get an exception.

/Users/alex/.rvm/gems/ruby-2.1.2/gems/sqlite_magic-0.0.3/lib/sqlite_magic.rb:49:in `rescue in execute': no such table: swdata (SqliteMagic::NoSuchTable)
  from /Users/alex/.rvm/gems/ruby-2.1.2/gems/sqlite_magic-0.0.3/lib/sqlite_magic.rb:42:in `execute'
  from /Users/alex/.rvm/gems/ruby-2.1.2/gems/scraperwiki-3.0.2/lib/scraperwiki.rb:186:in `select

How can I handle that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions