scratchpad:dmcmorris:dbdtest
Differences
This shows you the differences between two versions of the page.
| scratchpad:dmcmorris:dbdtest [2007/05/24 04:53] – created dmcmorris | scratchpad:dmcmorris:dbdtest [2022/02/10 13:34] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | The following is a simple Perl script to test the DBI and DBD connections. | ||
| + | < | ||
| + | # | ||
| + | |||
| + | # Constructed using the information available at | ||
| + | # http:// | ||
| + | # and input from http:// | ||
| + | # with modifications by dmcmorris for use as a test on the | ||
| + | # Evergreen project. | ||
| + | |||
| + | # PERL MODULES WE WILL BE USING | ||
| + | use DBI; | ||
| + | use DBD::Pg; | ||
| + | |||
| + | # CONFIG VARIABLES | ||
| + | $database = " | ||
| + | $host = " | ||
| + | $user = " | ||
| + | $pw = " | ||
| + | |||
| + | # PERL DBI CONNECT | ||
| + | $connect = DBI-> | ||
| + | || die " | ||
| + | |||
| + | # PREPARE THE QUERY | ||
| + | $query = " | ||
| + | $query_handle = $connect-> | ||
| + | |||
| + | # EXECUTE THE QUERY | ||
| + | $query_handle-> | ||
| + | |||
| + | # BIND TABLE COLUMNS TO VARIABLES | ||
| + | $query_handle-> | ||
| + | \$id, | ||
| + | \$parent_ou, | ||
| + | \$ou_type, | ||
| + | \$ill_address, | ||
| + | \$holds_address, | ||
| + | \$mailing_address, | ||
| + | \$billing_address, | ||
| + | \$shortname, | ||
| + | \$name, | ||
| + | \$email, | ||
| + | \$phone, | ||
| + | \$opac_visible | ||
| + | ); | ||
| + | |||
| + | # LOOP THROUGH RESULTS | ||
| + | while($query_handle-> | ||
| + | print "$id, $shortname, $name\n"; | ||
| + | } | ||
| + | </ | ||