Skip to content

Commit

Permalink
Clean out table on each run
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtmtmtm committed Apr 26, 2019
1 parent aff904e commit 4c414f4
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions scraper.rb
Expand Up @@ -8,16 +8,14 @@
require 'wikidata/area'

query = <<QUERY
SELECT DISTINCT ?item ?itemLabel
WHERE
{
SELECT DISTINCT ?item ?itemLabel WHERE {
{ ?item wdt:P31 wd:Q41806065 } UNION { ?item wdt:P31 wd:Q2914565 }.
}
QUERY

wanted = EveryPolitician::Wikidata.sparql(query)
raise 'No ids' if wanted.empty?

ScraperWiki.sqliteexecute('DELETE FROM data') rescue nil
data = Wikidata::Areas.new(ids: wanted).data
ScraperWiki.sqliteexecute('DROP TABLE data') rescue nil
ScraperWiki.save_sqlite(%i(id), data)

0 comments on commit 4c414f4

Please sign in to comment.