Class: Rays::Database::MySQL

Inherits:
Object
  • Object
show all
Defined in:
lib/rays/services/database.rb

Instance Method Summary collapse

Constructor Details

#initialize(host, port, username, password, db_name = nil) ⇒ MySQL

Returns a new instance of MySQL.



27
28
29
30
31
32
33
# File 'lib/rays/services/database.rb', line 27

def initialize(host, port, username, password, db_name=nil)
  @host = host
  @port = port
  @username = username
  @password = password
  @db_name = db_name
end

Instance Method Details

#create_database_command(db_name) ⇒ Object



43
44
45
# File 'lib/rays/services/database.rb', line 43

def create_database_command(db_name)
  "mysqladmin -u#{@username} #{pass_param} create #{db_name}"
end

#delete_database_command(db_name) ⇒ Object



47
48
49
# File 'lib/rays/services/database.rb', line 47

def delete_database_command(db_name)
  "mysqladmin -u#{@username} #{pass_param} -f drop #{db_name}"
end

#export_command(db_name, dump_file) ⇒ Object



35
36
37
# File 'lib/rays/services/database.rb', line 35

def export_command(db_name, dump_file)
  "mysqldump -u#{@username} #{pass_param} -h#{@host} --port=#{@port} #{db_name} > #{dump_file}"
end

#import_command(db_name, dump_file) ⇒ Object



39
40
41
# File 'lib/rays/services/database.rb', line 39

def import_command(db_name, dump_file)
  "mysql -u#{@username} #{pass_param} #{db_name} < #{dump_file}"
end