db starting
This commit is contained in:
parent
bdcdf9b80a
commit
c05bccfaa0
2 changed files with 48 additions and 6 deletions
|
@ -1,11 +1,16 @@
|
|||
CREATE TABLE "what" (id integer PRIMARY KEY,
|
||||
DROP TABLE IF EXISTS "videos";
|
||||
|
||||
CREATE TABLE "videos" (
|
||||
id integer PRIMARY KEY AUTOINCREMENT,
|
||||
camera integer not null,
|
||||
filename text not null,
|
||||
status text not null,
|
||||
status text not null, -- qw/known downloading downloaded syncing synced/
|
||||
filesize integer,
|
||||
filetype text not null,
|
||||
lastseen text default datetime(now) not null,
|
||||
firstseen text default datetime(now) not null,
|
||||
filetype text not null, -- qw/video gps accel/
|
||||
lastseen text default current_timestamp not null,
|
||||
firstseen text default current_timestamp not null,
|
||||
downloadedat text,
|
||||
syncedat text
|
||||
syncedat text,
|
||||
UNIQUE(camera, filename)
|
||||
);
|
||||
|
||||
|
|
37
downloader/lib/App/DB.pm
Normal file
37
downloader/lib/App/DB.pm
Normal file
|
@ -0,0 +1,37 @@
|
|||
package App::DB;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use DBI;
|
||||
|
||||
my $dbh = DBI->connect('dbi:SQLite:dbname=files.db','','');
|
||||
|
||||
sub insert_file {
|
||||
my ($filename, $camera) = @_;
|
||||
|
||||
my $filetype = "unknown";
|
||||
$filetype = "video" if ($filename =~ /mp4$/);
|
||||
$filetype = "thumbnail" if ($filename =~ /mp4$/);
|
||||
$filetype = "gps" if ($filename =~ /gps$/);
|
||||
$filetype = "accel" if ($filename =~ /3gf$/);
|
||||
|
||||
state $sth = $dbh->prepare(q{INSERT INTO videos (filename, camera, status, filetype) VALUES (?, ?, 'known', ?)});
|
||||
|
||||
return $sth->execute($filename, $camera, $filetype);
|
||||
}
|
||||
|
||||
sub update_file {
|
||||
my ($filename, $camera, %meta) = @_;
|
||||
}
|
||||
|
||||
sub get_file {
|
||||
}
|
||||
|
||||
sub have_file {
|
||||
}
|
||||
|
||||
sub file_status {
|
||||
}
|
||||
|
||||
1;
|
Loading…
Add table
Reference in a new issue