Sha256: d984905088d3ed32bf4ea6c413bd330b5d26b7c252b5c1bab1b160addd841baf

Contents?: true

Size: 691 Bytes

Versions: 9

Compression:

Stored size: 691 Bytes

Contents

require 'mysql2'
require 'dotenv/load'

user_name = 'dummy'
env = 'test'
db_name = "#{user_name}_#{env}_db"
pass = ENV['DB_PASS']

puts '---[ CREATE DATABASE ]------------------ '
puts "\t\t user_name = #{user_name}"
puts "\t\t env = #{env}"
puts "\t\t db_name = #{db_name}"

begin
  client = Mysql2::Client.new(:host => "localhost", :username => "root", :password => pass)
  client.query("CREATE DATABASE #{db_name};")
  client.query("GRANT ALL PRIVILEGES ON #{db_name}.* TO #{user_name}@localhost IDENTIFIED by '#{pass}';")
  client.query("FLUSH PRIVILEGES;")
rescue => e
  puts "\t\t #{e}"
end

# puts '---[ FILL DATABASE ]-------------------- '
# %x`mysql -uroot -p #{db_name} < db.sql`

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
c80_contest-0.1.9 create_base.rb
c80_contest-0.1.8 create_base.rb
c80_contest-0.1.7 create_base.rb
c80_contest-0.1.6 create_base.rb
c80_contest-0.1.5 create_base.rb
c80_contest-0.1.4 create_base.rb
c80_contest-0.1.3 create_base.rb
c80_contest-0.1.2 create_base.rb
c80_contest-0.1.1 create_base.rb