Data-ObjectDriver

 view release on metacpan or  search on metacpan

lib/Data/ObjectDriver/Driver/DBD/SQLite.pm  view on Meta::CPAN

        }
    }
    return;
}

sub map_error_code {
    my $dbd = shift;
    my($code, $msg) = @_;

    if ($msg && $msg =~ /(?:not unique|UNIQUE constraint failed)/) {
        return Data::ObjectDriver::Errors->UNIQUE_CONSTRAINT;
    } else {
        return;
    }
}


sub bulk_insert {
    my $dbd = shift;
    my $dbh = shift;
    my $table = shift;

    my $cols = shift;
    my $rows_ref = shift;
    my $attrs = shift || {};

    my $sql = "INSERT INTO $table("  . join(',', @{$cols}) . ") VALUES (" . join(',',  map {'?'} @{$cols}) .  ")\n";

    my $sth = $dbh->prepare($sql);

    foreach my $row (@{$rows_ref}) {
        my $i = 1;
        for (my $j = 0; $j < @$cols; $j++) {
            $sth->bind_param($i++, $row->[$j], $attrs->{$cols->[$j]});
        }
        $sth->execute;
    }

    # For now just write all data, at some point we need to lookup the
    # maximum packet size for SQL
    return 1;
}

1;

=pod

=head1 NAME

Data::ObjectDriver::Driver::DBD::SQLite - SQLite driver

=head2 DESCRIPTION

This class provides an interface to the SQLite (L<http://sqlite.org>)
database through DBI.

=head2 NOTES & BUGS

This is experimental.

With the 1.11 version of L<DBD::SQLite> Blobs are handled transparently,
so C<bind_param_attributes> is optional.
With previous version of L<DBD::SQLite> users have experimented issues
with binary data in CHAR (partially solved by the DBI::SQL_BINARY binding).

=cut



( run in 1.383 second using v1.01-cache-2.11-cpan-39bf76dae61 )