Method: DBI.connect
- Defined in:
- lib/dbi.rb
.connect(driver_url, user = nil, auth = nil, params = nil, &p) ⇒ Object
Establish a database connection.
Format goes as such: “dbi:Driver:database_conn_args”
-
“dbi” is the literal string “dbi”. Case is unimportant.
-
“Driver” is the case-dependent name of your database driver class. The file “dbd/#Driver” will be required. If you are using rubygems to control your DBDs and DBI, you must make the gem’s file path available via the “gem” command before this will work.
-
database_conn_args can be:
-
The database name.
-
A more complex key/value association (to indicate host, etc). This is driver dependent; you should consult your DBD documentation.
-
143 144 145 146 147 148 |
# File 'lib/dbi.rb', line 143 def connect(driver_url, user=nil, auth=nil, params=nil, &p) dr, db_args = _get_full_driver(driver_url) dh = dr[0] # driver-handle dh.convert_types = @@convert_types @@last_connection = dh.connect(db_args, user, auth, params, &p) end |