Class: Itds::Client
- Inherits:
-
Object
- Object
- Itds::Client
- Extended by:
- Forwardable
- Defined in:
- lib/itds/client.rb
Constant Summary collapse
- DEFAULT_OPTS =
{ port: 1433, username: 'sa', timeout: 5, }
- DEFAULT_CONN_SETTINGS =
The default connection settings according to: stackoverflow.com/questions/9235527/incorrect-set-options-error-when-building-database-project
{ 'ANSI_NULLS' => 'ON', 'ANSI_PADDING' => 'ON', 'ANSI_WARNINGS' => 'ON', 'ARITHABORT' => 'ON', 'CONCAT_NULL_YIELDS_NULL' => 'ON', 'NUMERIC_ROUNDABORT' => 'OFF', 'QUOTED_IDENTIFIER' => 'ON' }
Instance Method Summary collapse
- #execute(sql) ⇒ Object
- #init_env ⇒ Object
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
- #new_backend(opts) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
28 29 30 31 32 33 34 35 36 |
# File 'lib/itds/client.rb', line 28 def initialize(opts={}) opts = DEFAULT_OPTS.merge(opts) opts[:azure] = true if(opts[:database]) opts[:login_timeout] = opts[:timeout] @backend = new_backend(opts) init_env @backend end |
Instance Method Details
#execute(sql) ⇒ Object
48 49 50 51 |
# File 'lib/itds/client.rb', line 48 def execute(sql) res = @backend.execute(sql) res end |
#init_env ⇒ Object
42 43 44 45 46 |
# File 'lib/itds/client.rb', line 42 def init_env DEFAULT_CONN_SETTINGS.each do |k,v| @backend.execute("SET #{k} #{v}") end end |
#new_backend(opts) ⇒ Object
38 39 40 |
# File 'lib/itds/client.rb', line 38 def new_backend(opts) TinyTds::Client.new(opts) end |