Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for azure databases #40

Merged
merged 1 commit into from
Dec 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions bin/slacker
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ end

# Preset the application to run on the console
Slacker.configure do |config|
config.console_enabled = true

# Setup the target connection based on the contents in database.yml
db_config = db_config_from_file(config.expand_path('database.yml'))

Expand All @@ -25,8 +23,8 @@ Slacker.configure do |config|
config.db_password = db_config["password"]
config.db_port = db_config["port"] if !!db_config["port"]
config.db_driver = db_config["driver"] if !!db_config["driver"]
# Override console_enabled value with the value from configuration yaml
config.console_enabled = db_config["console_enabled"] if db_config["console_enabled"] != nil
config.azure = db_config["azure"] if !!db_config["azure"]
config.console_enabled = db_config["console_enabled"] if !!db_config["console_enabled"]
end

if Slacker.application.run
Expand Down
3 changes: 2 additions & 1 deletion lib/slacker/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ def configure_db_tiny_tds
:password => @configuration.db_password,
:host => @configuration.db_server,
:database => @configuration.db_name,
:port => @configuration.db_port
:port => @configuration.db_port,
:azure => @configuration.azure

@database.query_options[:symbolize_keys] = true
rescue TinyTds::Error => e
Expand Down
16 changes: 14 additions & 2 deletions lib/slacker/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
module Slacker
class Configuration
attr_accessor :base_dir, :error_stream, :output_stream, :formatter, :db_server, :db_name, :db_user, :db_password, :db_port, :db_driver, :console_enabled
attr_accessor :base_dir,
:error_stream,
:output_stream,
:formatter,
:db_server,
:db_name,
:db_user,
:db_password,
:db_port,
:db_driver,
:azure,
:console_enabled

def initialize
@console_enabled = true
@base_dir = Dir.pwd
@error_stream = nil
@output_stream = nil
Expand All @@ -15,6 +25,8 @@ def initialize
@db_password = nil
@db_port = 1433
@db_driver = 'odbc'
@azure = false
@console_enabled = true
end

def expand_path(path)
Expand Down
4 changes: 4 additions & 0 deletions lib/slacker_new/project/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
# See https://github.com/vassilvk/slacker/wiki/Slacker-Project#odbc-vs-tds for more information.
driver: odbc

# Enable connections to azure databases.
# Applies only to tiny_tds driver.
azure: false

# Full instance name when using odbc; hostname or IP when using tiny_tds.
server: my_server

Expand Down