Skip to content

Commit

Permalink
Add index, do not store duplicate records
Browse files Browse the repository at this point in the history
  • Loading branch information
katkad committed Apr 26, 2017
1 parent 1f3fb8a commit 1458a12
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scraper.pl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
'agent' => 'Mozilla/5.0',
);

$dt->create_table(
{'Odbor' => 'text',
'Zkratka' => 'text'},
'data');
$dt->create_index(['Odbor'], undef, 'IF NOT EXISTS', 'UNIQUE');

# Get base root.
print 'Page: '.$base_uri->as_string."\n";
my $root = get_root($base_uri);
Expand All @@ -41,7 +47,7 @@
if ($department =~ m/^Odbor/ms) {
my $shortcut = dep_shortcut($department);
print 'Department: '.encode_utf8($department)."\n";
$dt->insert({
$dt->upsert({
'Odbor' => $department,
'Zkratka' => $shortcut,
});
Expand Down

0 comments on commit 1458a12

Please sign in to comment.