Oryx::DBI::Util::SQLite - Oryx DBI utilities for SQLite connections


Oryx documentation Contained in the Oryx distribution.

Index


Code Index:

NAME

Top

Oryx::DBI::Util::SQLite - Oryx DBI utilities for SQLite connections

DESCRIPTION

Top

This provides an Oryx DBI utility class for use with DBD::SQLite.

SEE ALSO

Top

Oryx::DBI::Util, DBD::Pg

AUTHORS

Top

Richard Hundt <richard NO SPAM AT protea-systems.com>

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

Top


Oryx documentation Contained in the Oryx distribution.

package Oryx::DBI::Util::SQLite;

use base qw(Oryx::DBI::Util);

our %SQL_TYPES = (
    'Oid'       => 'integer PRIMARY KEY AUTOINCREMENT',
    'Integer'   => 'integer',
    'String'    => 'text',
    'Text'      => 'text',
    'Binary'    => 'blob',
    'Float'     => 'real',
    'Boolean'   => 'integer',
    'DateTime'  => 'text',
);

sub type2sql {
    my ($self, $type, $size) = @_;
    my $sql_type = $SQL_TYPES{$type};
    return $sql_type;
}

# Columns may not be dropped in SQLite. Oh, well.
sub column_drop { }

sub table_exists {
    my ($self, $dbh, $table) = @_;
    my $sth = $dbh->table_info('%', '%', $table);
    $sth->execute();
    my @rv = @{$sth->fetchall_arrayref};
    $sth->finish;
    return grep { lc $_->[2] eq lc $table } @rv;
}

1;