summaryrefslogtreecommitdiffstats
path: root/bin/converter.pl
blob: e1a2aa93ad32f8dfc4c55bbaa3256b6eaad8abcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl

use warnings;
use strict;
use strict 'vars';

use DBI;

my $dbfile = 'ksiazki.db';
my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile", "", "");

my($id,$isbn,$title,$author,$owner,$state,$who,$can_borrow,$reserved,$comment);


open (INPUT,"ksiazki");

my $_ = <INPUT>;

while ($_)
{
	($id,$isbn,$title,$author,$owner,$can_borrow) = split(/,/,$_);
	chomp $can_borrow;
	if($can_borrow eq 'Tak')
	{
		$can_borrow = 1;
	}
	else
	{
		$can_borrow = 0;
	}
	$dbh->do("insert into ksiazki values ($id,$isbn,'$title','$author','$owner',1,'nikt',$can_borrow,0,'')");
	$_ = <INPUT>;
}