Top Level Namespace
Defined Under Namespace
Classes: Coopy, CoopyResult, DiffColumns, DiffOutput, DiffOutputAction, DiffOutputGroup, DiffOutputRaw, DiffOutputTable, DiffOutputTdiff, DiffParser, DiffRenderCsv, DiffRenderHtml, DiffRenderLog, RowChange, ScraperwikiSqlWrapper, SequelSqlBare, SequelSqlWrapper, SqlCompare, SqlWrapper, SqliteSqlWrapper
Instance Method Summary
collapse
Instance Method Details
#link_tables(watch_scraper, watch_tables) ⇒ Object
1
2
3
4
|
# File 'lib/coopy/scraperwiki_utils.rb', line 1
def link_tables(watch_scraper,watch_tables)
sql = ScraperwikiSqlWrapper.new(ScraperWiki)
watch_tables.each { |tbl| sql.copy_table_structure(watch_scraper,tbl) }
end
|
#sync_table(watch_scraper, tbl, keys) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/coopy/scraperwiki_utils.rb', line 10
def sync_table(watch_scraper,tbl,keys)
sql = ScraperwikiSqlWrapper.new(ScraperWiki)
sql.set_primary_key(keys) unless keys.nil?
cmp = SqlCompare.new(sql,"main.#{tbl}","#{watch_scraper}.#{tbl}")
sinks = DiffOutputGroup.new
render = DiffRenderHtml.new
sinks << render
sinks << DiffApplySql.new(sql,"main.#{tbl}")
cmp.set_output(sinks)
cmp.apply
result = CoopyResult.new
result.html = render.to_string
result
end
|