Class: Bozo::Preparers::SqlServer

Inherits:
Object
  • Object
show all
Defined in:
lib/bozo/preparers/sql_server.rb

Overview

Executes a sql script

Hook configuration

prepare :sql_server do |t|
  t.variable 'DatabaseName', 'MyDatabase'
  t.variable 'MySecondVariable', 'HelloWorld'
  t.script 'my/specific/script.sql' # must be a specific file
  t.connection_string { |c| c[:config_value] } # a function taking the configuration as an argument
end

The variables are accessible via ‘$(KEY)` in the sql script.

Instance Method Summary collapse

Instance Method Details

#connection_string(&value) ⇒ Object



32
33
34
# File 'lib/bozo/preparers/sql_server.rb', line 32

def connection_string(&value)
  @connection_string = value
end

#executeObject



17
18
19
20
21
# File 'lib/bozo/preparers/sql_server.rb', line 17

def execute
  configuration = load_config

  execute_command :sqlcmd, generate_args(configuration)
end

#script(value) ⇒ Object



28
29
30
# File 'lib/bozo/preparers/sql_server.rb', line 28

def script(value)
  @script = value
end

#variable(key, value) ⇒ Object



23
24
25
26
# File 'lib/bozo/preparers/sql_server.rb', line 23

def variable(key, value)
  @variables ||= {}
  @variables[key] = value
end