Skip to content

Instantly share code, notes, and snippets.

@samleb
Forked from goguelu/gist:150328
Created July 20, 2009 13:03
Show Gist options
  • Save samleb/150329 to your computer and use it in GitHub Desktop.
Save samleb/150329 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'active_record'
require 'active_support'
require 'parseconfig'
config = ParseConfig.new( '/path/to/conf/file.conf' )
db_number = Integer(config.get_value( 'database_count' ))
database_parameters = (1...db_number).collect do |i|
db = config.get_value("DB#{i}")
db[1..-2].split(',')
end
counts = database_parameters.collect do |params|
ActiveRecord::Base.establish_connection(
:adapter => params[0],
:host => params[1],
:port => Integer(params[2]),
:database => params[3],
:username => params[4],
:password => params[5]
)
class Order < ActiveRecord::Base
set_table_name "Orders"
end
Order.count('ID')
end
if counts.all? { |c| c == counts.first }
puts "OK"
else
db_parameters.each do |params|
puts "démerde toi avec ton message d'output :)"
end
exit 2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment