DBI_DSN
, DBI_USER
and DBI_PASS
environment variables before running my Perl script?Not unless your Perl script uses these environment variables.
The DBD::ODBC installation and test procedure requires these environment variables to be set, because they call DBI->connect
without any arguments:
$dbh = DBI->connect($data_source, $username, $password, \%attr)
The $data_source
value must begin with dbi:driver_name:
. The driver_name
specifies the driver that makes the connection. (Case is significant.)
As a convenience, if the $data_source
parameter is undefined or empty, the DBI module uses the DBI_DSN
value. If driver_name
is missing (the $data_source
prefix is dbi::
), the DBI module uses the DBI_DRIVER
value. If neither variable is set, connect
dies.
If $username
or $password
are undefined (rather than just empty), the DBI module uses the DBI_USER
and DBI_PASS
values. DBI generates a warning if the environment variables are undefined.
The Perl DBI documentation suggests that using these environment variables is not recommended for security reasons and that this mechanism is intended to simplify testing. To avoid using the DBI_xyz
environment variables, specify the values directly in the DBI->Connect
call:
DBI->Connect('dbi:ODBC:dsn_name', 'username', 'password')
Alternatively, you can prompt for the user name and password.