| 3 |
- |
1 |
package WebDB;
|
|
|
2 |
use strict;
|
|
|
3 |
use DBI;
|
|
|
4 |
my $host_name = "192.168.1.5";
|
|
|
5 |
my $db_name = "CoffeeCatalogDB";
|
|
|
6 |
my $dsn = "DBI:mysql:host=$host_name;database=$db_name";
|
|
|
7 |
# Connect to MySQL server, using hardwired name and password
|
|
|
8 |
sub connect {
|
|
|
9 |
return (DBI->connect ($dsn, "root", "Jopy666!",
|
|
|
10 |
{PrintError => 0, RaiseError => 1}));
|
|
|
11 |
}
|
|
|
12 |
# Connect to MySQL server, using name and password from the current
|
|
|
13 |
# user's ~/.my.cnf option file. The mysql_read_default_file option,
|
|
|
14 |
# when added to the DSN, specifies which option file to read.
|
|
|
15 |
sub connect_with_option_file {
|
|
|
16 |
$dsn .= ";mysql_read_default_file=$ENV{HOME}/.my.cnf";
|
|
|
17 |
return (DBI->connect ($dsn, undef, undef,
|
|
|
18 |
{PrintError => 0, RaiseError => 1}));
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
1; # return true
|