commit f1d32b286f1ab8c0f72c4839e7c2a884a20fcded
parent 6ee17a69b0d33a1e6cc68985884e30b3faaf3a80
Author: Kyle R W Milz <kyle@getaddrinfo.net>
Date: Wed, 13 Aug 2014 22:44:26 -0600
pricechart.db: store/get db file name from config file
Diffstat:
4 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/Shared.pm b/Shared.pm
@@ -41,7 +41,14 @@ sub get_config
},
},
general => {
- _vars => ['http_path', 'log_path', 'user_agent', 'email', 'smtp'],
+ _vars => [
+ 'http_path',
+ 'log_path',
+ 'user_agent',
+ 'email',
+ 'smtp',
+ 'db_file'
+ ],
},
});
diff --git a/price_scraper.pl b/price_scraper.pl
@@ -18,7 +18,7 @@ getopts('f:np:v', \%args);
my $cfg = get_config($args{f});
my $dbh = DBI->connect(
- "dbi:SQLite:dbname=pricechart.db",
+ "dbi:SQLite:dbname=$cfg->{general}{db_file}",
"",
"",
{ RaiseError => 1 },) or die $DBI::errstr;
diff --git a/pricechart.cfg b/pricechart.cfg
@@ -6,6 +6,7 @@ log_path = pricechart_log.txt
user_agent = Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36;
email = kyle@getaddrinfo.net
smtp = smtp.getaddrinfo.net
+db_file = pricechart.db
*** vendors ***
diff --git a/product_scraper.pl b/product_scraper.pl
@@ -22,7 +22,7 @@ my $cfg = get_config($args{f});
$| = 1 if ($args{v});
my $dbh = DBI->connect(
- "dbi:SQLite:dbname=pricechart.db",
+ "dbi:SQLite:dbname=$cfg->{general}{db_file}",
"",
"",
{ RaiseError => 1 },) or die $DBI::errstr;