Skip to content

Instantly share code, notes, and snippets.

@workmaster2n
Created August 5, 2013 22:10
Show Gist options
  • Select an option

  • Save workmaster2n/6160042 to your computer and use it in GitHub Desktop.

Select an option

Save workmaster2n/6160042 to your computer and use it in GitHub Desktop.
Pseudo replication
# From remote
Connect(home_base, username, password)
last_id_replicated = SELECT highest_replicated_id FROM replication_information WHERE computer = self.name
Connect(local_db, username, password)
to_replicate = local_machine.SELECT * FROM tracked_points WHERE id > last_id_replicated
to_replicate.every_thousand_records
start_transaction
INSERT INTO home_base.big_table (computer_name, x, y, recorded_at) VALUES (self.name, thousand_records.x, thousand_records.y, thousand_records.recorded_at)
UPDATE replication_information SET last_updated_at = Time.now, highest_replicated_id = thousand_records.last.id WHERE computer_name = self.name
end_transaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment