Class::DBI::ClassGenerator::DBD::SQLite - SQLite-specific helper module


Class-DBI-ClassGenerator documentation Contained in the Class-DBI-ClassGenerator distribution.

Index


Code Index:

NAME

Top

Class::DBI::ClassGenerator::DBD::SQLite - SQLite-specific helper module for Class::DBI::ClassGenerator.

You should never have to use this module directly. It is only of interest if hacking on the main module, or for those wishing to add support for another type of database.

See Class::DBI::ClassGenerator::Extending for details.

BUGS and WARNINGS

Top

This should be considered to be pre-production code. It's probably chock full of exciting bugs.

AUTHOR, COPYRIGHT and LICENCE

Top


Class-DBI-ClassGenerator documentation Contained in the Class-DBI-ClassGenerator distribution.
# $Id: SQLite.pm,v 1.3 2008-08-28 17:07:11 cantrelld Exp $

package Class::DBI::ClassGenerator::DBD::SQLite;

use strict;
use warnings;

use vars qw($VERSION);

$VERSION = '1.0';

sub _get_tables {
    my(undef, $dbh) = @_;

    return map { @{$_} } @{$dbh->selectall_arrayref("SELECT name FROM sqlite_master WHERE type='table'")};
}

sub _get_columns {
    my(undef, $dbh, $table) = @_;

    my $data = $dbh->selectall_hashref("PRAGMA table_info($table)", 'name');
    return map {
        $_ => {
            type    => '', # $data->{$_}->{type}
            null    => !$data->{$_}->{notnull},
            pk      => $data->{$_}->{pk},
            default => $data->{$_}->{dflt_value}
        }
    } keys %{$data}
}

1;