Catalyst-Plugin-AutoCRUD

 view release on metacpan or  search on metacpan

examples/sql/bootstrap_sqlite.pl  view on Meta::CPAN

#!/usr/bin/perl

# this small program (originally written by Andy) will create an SQLite3 DB 
# from the .sql file in this same directory.
# just run it as: perl ./bootstrap_sqlite.pl

use DBI;
use Data::Dumper;

foreach my $name (qw/demo_app other_features/) {
    my $dbfile = "__autocrud_$name.sqlite";

    if (-e $dbfile) { unlink $dbfile or die "Failed to unlink $dbfile: $!"; }

    my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile",'','',{ sqlite_unicode => 1 });

    open my $sql_fh, "$name.sql" or die "Can't read SQL file: $!";
    local $/ = "";  ## empty line(s) are delimeters
    while (my $sql = <$sql_fh>) {
        print $sql;
        $dbh->do($sql);
    }

    # to test it went in okay
    # print Dumper $dbh->selectall_arrayref('SELECT * FROM artist', { Slice => {} });

    $dbh->disconnect;
    close $sql_fh;
}

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 2.150 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )