Class: DBI::DriverHandle

### Home Classes Methods

### In Files

- lib/dbi/handles/driver.rb

### Parent

Handle

### Methods

- #connect
- #data_sources
- #disconnect_all

### Files

- ChangeLog
- LICENSE
- README

### Class/Module Index

Quicksearch

- DBI
- DBI::BaseDatabase
- DBI::BaseDriver
- DBI::BaseStatement
- DBI::Binary
- DBI::ColumnInfo
- DBI::DataError
- DBI::DatabaseError
- DBI::DatabaseHandle
- DBI::Date
- DBI::DriverHandle
- DBI::Error
- DBI::Handle
- DBI::HandleTracer
- DBI::IntegrityError
- DBI::InterfaceError
- DBI::InternalError
- DBI::NotImplementedError
- DBI::NotSupportedError
- DBI::OperationalError
- DBI::ProgrammingError
- DBI::Row
- DBI::SQL
- DBI::SQL::PreparedStatement
- DBI::StatementHandle
- DBI::Time
- DBI::Timestamp
- DBI::Type
- DBI::Type::Boolean
- DBI::Type::Decimal
- DBI::Type::Float
- DBI::Type::Integer
- DBI::Type::Null
- DBI::Type::Timestamp
- DBI::Type::Varchar
- DBI::TypeUtil
- DBI::Utils
- DBI::Utils::ConvParam
- DBI::Utils::TableFormatter
- DBI::Utils::XMLFormatter
- DBI::Warning
- Class

No matching classes.

# DBI::DriverHandle

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

### Attributes

driver_name[W]

### Public Instance Methods

connect(db_args, user, auth, params) click to toggle source

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.

    # File lib/dbi/handles/driver.rb, line 15
    def connect(db_args, user, auth, params)

        user = @handle.default_user[0] if user.nil?
        auth = @handle.default_user[1] if auth.nil?

        # TODO: what if only one of them is nil?
        #if user.nil? and auth.nil? then
        #  user, auth = @handle.default_user
        #end

        params ||= {}
        new_params = @handle.default_attributes
        params.each {|k,v| new_params[k] = v}

        if params.has_key?(:_convert_types)
            @convert_types = params[:_convert_types]
        end

        db = @handle.connect(db_args, user, auth, new_params)
        dbh = DatabaseHandle.new(db, @convert_types)
        # FIXME trace
        # dbh.trace(@trace_mode, @trace_output)
        dbh.driver_name = @driver_name

        if block_given?
            begin
                yield dbh
            ensure
                dbh.disconnect if dbh.connected?
            end
        else
            return dbh
        end
    end

data_sources() click to toggle source

See BaseDriver#data_sources.

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

disconnect_all() click to toggle source

See BaseDriver#disconnect_all.

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.