
Untitled
By: a guest on
May 4th, 2012 | syntax:
None | size: 0.91 KB | hits: 9 | expires: Never
class LinkGraph
attr_accessor :crawler_id, :crawl_date
LOCAL_DB = {:adapter => "postgresql", :host => "localhost", :database => "development234", :username => "hello", :password => "howdy" }
def table_name
"#{crawler_id}__#{crawl_date.gsub("/","_")}__linkgraph"
end
def initialize_activerecord
ActiveRecord::Base.establish_connection(LOCAL_DB)
end
def create_table
if @crawler_id.blank? || @crawl_date.blank?
puts "Need Crawler ID and Crawl Date to use temporary tables. "
return false
end
ActiveRecord::Base.connection.execute(
"CREATE TABLE #{table_name}
(page_url text,
page_id integer,
destination_url text,
destination_code integer,
destination char(50));"
)
end
class LinkGraphchild < ActiveRecord::Base
set_table_name table_name
end