1 package DBIx::Class::Storage::DBI::SQLite;
9 use base qw/DBIx::Class::Storage::DBI::MultiDistinctEmulation/;
11 sub _dbh_last_insert_id {
12 my ($self, $dbh, $source, $col) = @_;
13 $dbh->func('last_insert_rowid');
18 my ($self, $dir) = @_;
21 ## Where is the db file?
22 my $dsn = $self->connect_info()->[0];
24 my $dbname = $1 if($dsn =~ /dbname=([^;]+)/);
27 $dbname = $1 if($dsn =~ /^dbi:SQLite:(.+)$/i);
29 $self->throw_exception("Cannot determine name of SQLite db file")
30 if(!$dbname || !-f $dbname);
32 # print "Found database: $dbname\n";
33 # my $dbfile = file($dbname);
34 my ($vol, $dbdir, $file) = File::Spec->splitpath($dbname);
35 # my $file = $dbfile->basename();
36 $file = strftime("%Y-%m-%d-%H_%M_%S", localtime()) . $file;
37 $file = "B$file" while(-f $file);
39 mkdir($dir) unless -f $dir;
40 my $backupfile = File::Spec->catfile($dir, $file);
42 my $res = copy($dbname, $backupfile);
43 $self->throw_exception("Backup failed! ($!)") if(!$res);
53 DBIx::Class::Storage::DBI::SQLite - Automatic primary key class for SQLite
57 # In your table classes
58 __PACKAGE__->load_components(qw/PK::Auto Core/);
59 __PACKAGE__->set_primary_key('id');
63 This class implements autoincrements for SQLite.
67 Matt S. Trout <mst@shadowcatsystems.co.uk>
71 You may distribute this code under the same terms as Perl itself.