1: require 'dbi'
2:
3: db = DBI.connect(
4: "DBI:Pg:jim",
5: user,
6: password)
7: # Use the database
8: db.disconnect # When done
|
|
- [1] Require the DBI library.
- [3-6] Create a database connection. The DBI module interprets the "DBI:xxx:yyy" string to determine the Type of database ("Pg" in this example) and the database (e.g. "jim").
- The DBI software will find the correct DBD driver for the DBI string and automatically load it.
- [8] Disconnect from the database when you are done.
|