@@log.debug("issuing COPY to #{table_name} from #{file}")
raw=GeoIpBlocks.connection.raw_connection
result=raw.copy_data"COPY #{table_name} FROM STDIN"do
File.open(file,'r').eachdo|line|
raw.put_copy_dataline
end
end
count=GeoIpBlocks.connection.select_value("select count(*) from #{table_name}").to_i
ActiveRecord::Base.logger.debug"loaded #{count} records into #{table_name}"
end
defself.copy_table(table_name)
copied_name="#{table_name}_copied"
GeoIpBlocks.connection.execute"CREATE TABLE #{copied_name} (LIKE #{table_name} INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING COMMENTS INCLUDING STORAGE)"