15 my $class=ref($proto) || $proto;
19 my($dir, $init, $me)=@_;
20 $self->{dbpath}="$dir/$dbfile";
23 my $exists=-f $self->{dbpath};
24 die("$me: $self->{dbpath}: not found. use --init to create.\n") if(!$exists && !$init);
25 die("$me: --init used but $self->{dbpath} exists.\n") if($exists && $init);
27 $self->{dbh}=DBI->connect("dbi:SQLite:dbname=$self->{dbpath}","","",
29 unless(defined($self->{dbh}))
31 die("$me: DB Error: " . $DBI::errstr . "\n");
49 my @schema=split(/\n\n/,join("", <DATA>));
53 $self->{dbh}->do($cmd);
55 $self->cmd("INSERT INTO id3fs (schema_version) VALUES (?)", $SCHEMA_VERSION);
61 my ($version)=$self->cmd_onerow("SELECT schema_version from id3fs");
62 if(!defined($version) || $version != $SCHEMA_VERSION)
64 die("$self->{me}: id3fs database version " .
65 defined($version) ? $version : '""' .
66 "not known, current version is $SCHEMA_VERSION.\n");
72 my($self, $sql, @params)=@_;
73 my $sth=$self->{dbh}->prepare($sql);
75 for my $param (@params)
77 $param="" unless(defined($param));
78 $sth->bind_param($idx++, $param);
87 my $file=ID3FS::File->new($path);
93 # don't care about retcode
94 $self->cmd_sth(@args);
100 my $sth=$self->cmd_sth(@args);
101 return($sth->fetchrow_array());
111 id INTEGER PRIMARY KEY,
116 id INTEGER PRIMARY KEY,
120 CREATE TABLE tags_x_files (
125 CREATE TABLE v1genres (