my $self = shift;
foreach my $table ( $self->tables ) {
- my $dbh = $self->find_class($table)->storage->dbh;
+ my $dbh = $self->{_storage}->dbh;
my $sth = $dbh->prepare(<<"");
SELECT sql FROM sqlite_master WHERE tbl_name = ?
sub _tables {
my $self = shift;
- my $dbh = DBI->connect( @{ $self->{_datasource} } ) or croak($DBI::errstr);
+ my $dbh = $self->{_storage}->dbh;
my $sth = $dbh->prepare("SELECT * FROM sqlite_master");
$sth->execute;
my @tables;
next unless lc( $row->{type} ) eq 'table';
push @tables, $row->{tbl_name};
}
- $dbh->disconnect;
return @tables;
}
my ( $self, $table ) = @_;
# find all columns.
- my $dbh = DBI->connect( @{ $self->{_datasource} } ) or croak($DBI::errstr);
+ my $dbh = $self->{_storage}->dbh;
my $sth = $dbh->prepare("PRAGMA table_info('$table')");
$sth->execute();
my @columns;
$sth->execute($table);
my ($sql) = $sth->fetchrow_array;
$sth->finish;
- $dbh->disconnect;
my ($primary) = $sql =~ m/
(?:\(|\,) # either a ( to start the definition or a , for next
\s* # maybe some whitespace