Attributes


In addition to the connection string, the username and the password one can and should configure the database with the DBI specific configuration options (or attributes). These options all go in a HASH reference in the 4th parameter of the DBI connect method.

As the databases and the DBD - Database drivers might all decide arbitrarily on their mode regarding transactions one should always explicitly declare how she wants to operate.

The AutoCommit option.


examples/dbi/attributes.pl
my %attributes = (
    PrintError  => 1,
    RaiseError  => 1,
    AutoCommit  => 1,
    FetchHashKeyName => 'NAME_lc',  #   NAME_uc
    TraceLevel  => 1,  # see Debugging and Trace levels later
);

my $dsn = "dbi:SQLite:dbname=$dbfile";
my $dbh = DBI->connect($dsn, $username, $password, \%attributes);