DBD-CSV
view release on metacpan or search on metacpan
lib/DBD/CSV.pm view on Meta::CPAN
#!/usr/bin/perl
#
# DBD::CSV - A DBI driver for CSV and similar structured files
#
# This module is currently maintained by
#
# H.Merijn Brand <h.m.brand@xs4all.nl>
#
# See for full acknowledgements the last two pod sections in this file
use strict;
use warnings;
require DynaLoader;
require DBD::File;
require IO::File;
our @f_SHORT = qw( class file dir dir_search ext lock lockfile schema encoding );
our @c_SHORT = qw( eof
eol sep_char quote_char escape_char binary decode_utf8 auto_diag
diag_verbose blank_is_undef empty_is_undef allow_whitespace
allow_loose_quotes allow_loose_escapes allow_unquoted_escape
always_quote quote_empty quote_space escape_null quote_binary
keep_meta_info callbacks );
package DBD::CSV;
use strict;
our @ISA = qw( DBD::File );
our $VERSION = "0.62";
our $ATTRIBUTION = "DBD::CSV $DBD::CSV::VERSION by H.Merijn Brand";
our $err = 0; # holds error code for DBI::err
our $errstr = ""; # holds error string for DBI::errstr
our $sqlstate = ""; # holds error state for DBI::state
our $drh = undef; # holds driver handle once initialized
sub CLONE { # empty method: prevent warnings when threads are cloned
} # CLONE
# --- DRIVER -------------------------------------------------------------------
package DBD::CSV::dr;
use strict;
use Text::CSV_XS ();
our @CSV_TYPES = (
Text::CSV_XS::IV (), # SQL_TINYINT
Text::CSV_XS::IV (), # SQL_BIGINT
Text::CSV_XS::PV (), # SQL_LONGVARBINARY
Text::CSV_XS::PV (), # SQL_VARBINARY
Text::CSV_XS::PV (), # SQL_BINARY
Text::CSV_XS::PV (), # SQL_LONGVARCHAR
Text::CSV_XS::PV (), # SQL_ALL_TYPES
Text::CSV_XS::PV (), # SQL_CHAR
Text::CSV_XS::NV (), # SQL_NUMERIC
Text::CSV_XS::NV (), # SQL_DECIMAL
Text::CSV_XS::IV (), # SQL_INTEGER
Text::CSV_XS::IV (), # SQL_SMALLINT
Text::CSV_XS::NV (), # SQL_FLOAT
Text::CSV_XS::NV (), # SQL_REAL
Text::CSV_XS::NV (), # SQL_DOUBLE
);
our @ISA = qw( DBD::File::dr );
our $imp_data_size = 0;
our $data_sources_attr = undef;
sub connect {
my ($drh, $dbname, $user, $auth, $attr) = @_;
if ($attr && ref $attr eq "HASH") {
# Top-level aliasses
foreach my $key (grep { exists $attr->{$_} } @f_SHORT) {
my $f_key = "f_$key";
exists $attr->{$f_key} and next;
$attr->{$f_key} = delete $attr->{$key};
}
foreach my $key (grep { exists $attr->{$_} } @c_SHORT) {
my $c_key = "csv_$key";
( run in 0.643 second using v1.01-cache-2.11-cpan-39bf76dae61 )