 if ($driver_there->{processed} == 0) {
     die "Driver $driver is not available.  Can't look at database."
 }
+
+# set environment variables for initial connection
+local %ENV;
+$_SHARED{set_environment}->(
+    $params->{dbi_connection_environment}
+);
 
 my $attr_href = Load($params->{dbh_attributes});
 my $dbh = DBI->connect(

                }
            }
            else {
                die "In get_dbh, env_action may only be one of {overwrite, prepend, append}.";
            }
        }
    }

    $attribute_hashref = Load(
        $connection_info->{dbh_attributes}

    return $rv->{rows}[0];
},

set_environment => sub {
    use YAML;

    my $dbi_connection_environment = $_[0];

    if (defined $dbi_connection_environment) {
        my $parsed_env = Load($dbi_connection_environment);
        die "In set_environment, argument must be an array reference."
            unless (ref($parsed_env) eq 'ARRAY');
        foreach my $setting (@$parsed_env) {
            foreach my $key (qw(env_name env_value env_action)) {
                die "In set_environment, missing key $key"
                    unless (defined $setting->{$key});
            }
            if ($setting->{env_action} eq 'overwrite') {
