Closed mlessev closed 11 years ago
In ScraperWiki.save_sqlite(['country'], data2, 'test')
your key is a String, in data2
your key is a Hash.
Try changing your save_sqlite
call to ScraperWiki.save_sqlite([:country], data2, 'test')
Hello,
Thank you for your replay but it doesn't work too.
Anyway I have already find the problem and it is not in ScraperWiki.save_sqlite(['country'], data2, 'test') but in data2 definitions.
When I change
data2 = { id: 12, search_keyword: "test", country: "BG" }
with
data2 = { id => 12, search_keyword => "test", country => "BG" }
It works as I expected.
p.s I'm not a ruby expert and the code was migrated from https://classic.scraperwiki.com where it works - so I suppose the problem is in different interpreters
data2 = { id: 12, search_keyword: "test", country: "BG" }
ScraperWiki.save_sqlite(['country'], data2, 'test')
Return the following error:
Started run: 2013-07-30 18:59:17+00:00 /var/lib/gems/1.9.1/gems/sqlite_magic-0.0.2/lib/sqlite_magic.rb:83:in'
Finished run: 2013-07-30 18:59:18+00:00 Exit code: 1
block in save_data': Data has nil value for unique key. Unique keys are ["country"]. Offending data: {:id=>12, :search_keyword=>"test", :country=>"BG"} (SqliteMagic::DatabaseError) from /var/lib/gems/1.9.1/gems/sqlite_magic-0.0.2/lib/sqlite_magic.rb:80:in
each' from /var/lib/gems/1.9.1/gems/sqlite_magic-0.0.2/lib/sqlite_magic.rb:80:insave_data' from /var/lib/gems/1.9.1/gems/scraperwiki-3.0.1/lib/scraperwiki.rb:89:in
save_sqlite' from ./code/scraper:34:in `