Class: DBI::BaseDriver
Overview
Implements the basic functionality that constitutes a Driver
Drivers do not have a direct interface exposed to the user; these methods are mostly for DBD authors.
As with DBI::BaseDatabase, “DBD Required” and “DBD Optional” will be used to explain the same requirements.
Direct Known Subclasses
DBD::Mysql::Driver, DBD::ODBC::Driver, DBD::Pg::Driver, DBD::SQLite3::Driver, DBD::SQLite::Driver
Instance Method Summary collapse
-
#connect(dbname, user, auth, attr) ⇒ Object
Connect to the database.
-
#data_sources ⇒ Object
Return the data sources available to this driver.
-
#default_attributes ⇒ Object
Default attributes to set on the DatabaseHandle.
-
#default_user ⇒ Object
Default u/p information in an array.
-
#disconnect_all ⇒ Object
Disconnect all DatabaseHandles.
-
#initialize(dbi_version) ⇒ BaseDriver
constructor
A new instance of BaseDriver.
Constructor Details
#initialize(dbi_version) ⇒ BaseDriver
Returns a new instance of BaseDriver.
12 13 14 15 16 17 18 |
# File 'lib/dbi/base_classes/driver.rb', line 12 def initialize(dbi_version) major, minor = dbi_version.split(".").collect { |x| x.to_i } dbi_major, dbi_minor = DBI::VERSION.split(".").collect { |x| x.to_i } unless major == dbi_major and minor == dbi_minor raise InterfaceError, "Wrong DBD API version used #{major}.#{minor} != dbi #{dbi_major}.#{dbi_minor}" end end |
Instance Method Details
#connect(dbname, user, auth, attr) ⇒ Object
Connect to the database. DBD Required.
21 22 23 |
# File 'lib/dbi/base_classes/driver.rb', line 21 def connect(dbname, user, auth, attr) raise NotImplementedError end |
#data_sources ⇒ Object
Return the data sources available to this driver. Returns an empty array per default.
37 38 39 |
# File 'lib/dbi/base_classes/driver.rb', line 37 def data_sources [] end |
#default_attributes ⇒ Object
Default attributes to set on the DatabaseHandle.
31 32 33 |
# File 'lib/dbi/base_classes/driver.rb', line 31 def default_attributes {} end |
#default_user ⇒ Object
Default u/p information in an array.
26 27 28 |
# File 'lib/dbi/base_classes/driver.rb', line 26 def default_user ['', ''] end |
#disconnect_all ⇒ Object
Disconnect all DatabaseHandles. DBD Required.
42 43 44 |
# File 'lib/dbi/base_classes/driver.rb', line 42 def disconnect_all raise NotImplementedError end |