1 package DBIx::Class::Storage::DBI::SQLite;
6 use base qw/DBIx::Class::Storage::DBI/;
13 sub _dbh_last_insert_id {
14 my ($self, $dbh, $source, $col) = @_;
15 $dbh->func('last_insert_rowid');
20 my ($self, $dir) = @_;
23 ## Where is the db file?
24 my $dsn = $self->_dbi_connect_info()->[0];
26 my $dbname = $1 if($dsn =~ /dbname=([^;]+)/);
29 $dbname = $1 if($dsn =~ /^dbi:SQLite:(.+)$/i);
31 $self->throw_exception("Cannot determine name of SQLite db file")
32 if(!$dbname || !-f $dbname);
34 # print "Found database: $dbname\n";
35 # my $dbfile = file($dbname);
36 my ($vol, $dbdir, $file) = File::Spec->splitpath($dbname);
37 # my $file = $dbfile->basename();
38 $file = strftime("%Y-%m-%d-%H_%M_%S", localtime()) . $file;
39 $file = "B$file" while(-f $file);
41 mkdir($dir) unless -f $dir;
42 my $backupfile = File::Spec->catfile($dir, $file);
44 my $res = copy($dbname, $backupfile);
45 $self->throw_exception("Backup failed! ($!)") if(!$res);
50 sub datetime_parser_type { return "DateTime::Format::SQLite"; }
56 DBIx::Class::Storage::DBI::SQLite - Automatic primary key class for SQLite
60 # In your table classes
61 __PACKAGE__->load_components(qw/PK::Auto Core/);
62 __PACKAGE__->set_primary_key('id');
66 This class implements autoincrements for SQLite.
70 Matt S. Trout <mst@shadowcatsystems.co.uk>
74 You may distribute this code under the same terms as Perl itself.