commit 9cd97c701e5c857625a88900f20a6b177f32a1f3
parent 30faaba1f5d12f5d028e239536390dde68076cf4
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Thu,  6 Nov 2014 22:14:43 -0700
product_scraper: use selectrow_array for query
Diffstat:
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/product_scraper.pl b/product_scraper.pl
@@ -39,8 +39,6 @@ tee("$vendor\n");
 tee("=") for (1..length $vendor);
 tee("\n\n");
 
-my $exists_sth = $dbh->prepare("select * from products where part_num = ?");
-
 my $qry = "insert into products(part_num, manufacturer, description, type, " .
 	"first_seen, last_seen, last_scraped) values (?, ?, ?, ?, ?, ?, ?)";
 my $insert_sth = $dbh->prepare($qry);
@@ -110,8 +108,8 @@ for (keys %product_map) {
 			next;
 		}
 
-		$exists_sth->execute($part_num);
-		if ($exists_sth->fetchrow_arrayref()) {
+		my $sql = "select * from products where part_num = ?";
+		if ($dbh->selectrow_arrayref($sql, undef, $part_num)) {
 			$update_sth->execute(time, $part_num);
 			vprint("  ($part_num) $brand $description\n");
 			$old++;
@@ -131,7 +129,6 @@ for (keys %product_map) {
 		$new + $old, scalar @thumbnails, $new, time - $start));
 }
 
-$exists_sth->finish();
 $dbh->disconnect();
 
 my $e_mail = Email::Simple->create(