Class DBI::DriverHandle
In: lib/dbi/handles/driver.rb
Parent: Handle

DriverHandles, while not directly exposed, are essentially the backend for the facade that many DBI root-level methods communicate with.

Methods

Attributes

driver_name  [W] 

Public Instance methods

Connect to the database. The DSN will have been parsed at this point and the named parameters should need no explanation.

If a block is provided to DBI.connect, the connected DatabaseHandle will be provided as the first argument to the block, and the DatabaseHandle will be disconnected upon block exit.

[Source]

    # File lib/dbi/handles/driver.rb, line 15
15:         def connect(db_args, user, auth, params)
16: 
17:             user = @handle.default_user[0] if user.nil?
18:             auth = @handle.default_user[1] if auth.nil?
19: 
20:             # TODO: what if only one of them is nil?
21:             #if user.nil? and auth.nil? then
22:             #  user, auth = @handle.default_user
23:             #end
24: 
25:             params ||= {}
26:             new_params = @handle.default_attributes
27:             params.each {|k,v| new_params[k] = v} 
28: 
29:             if params.has_key?(:_convert_types)
30:                 @convert_types = params[:_convert_types]
31:             end
32: 
33:             db = @handle.connect(db_args, user, auth, new_params)
34:             dbh = DatabaseHandle.new(db, @convert_types)
35:             # FIXME trace
36:             # dbh.trace(@trace_mode, @trace_output)
37:             dbh.driver_name = @driver_name
38: 
39:             if block_given?
40:                 begin
41:                     yield dbh
42:                 ensure  
43:                     dbh.disconnect if dbh.connected?
44:                 end  
45:             else
46:                 return dbh
47:             end
48:         end

See BaseDriver#data_sources.

[Source]

    # File lib/dbi/handles/driver.rb, line 51
51:         def data_sources
52:             @handle.data_sources
53:         end

See BaseDriver#disconnect_all.

[Source]

    # File lib/dbi/handles/driver.rb, line 56
56:         def disconnect_all
57:             @handle.disconnect_all
58:         end

[Validate]