perl5-dbi / dbd-csv Goto Github PK
View Code? Open in Web Editor NEWDBD::CSV - DBI driver for CSV files
DBD::CSV - DBI driver for CSV files
Hi everyone,
I've taken the example from the SYNOPSIS and added a line with the content of csv_class => 'Text::CSV_XS'
to it:
use strict;
use warnings;
use DBI;
# See "Creating database handle" below
my $dbh = DBI->connect("dbi:CSV:", undef, undef, {
f_ext => ".csv/r", RaiseError => 1,
csv_class => 'Text::CSV_XS'
}) or die "Cannot connect: $DBI::errstr";
$dbh->do ("CREATE TABLE foo (id INTEGER, name CHAR (10))");
Though I expected to change nothing, because Text::CSV_XS
should be the default value, my programm now fails. With the help of Carp::Always I got this error stacktrace:
DBD::CSV::db do failed: Can't call method "print" on an undefined value at /home/ba01m/perl5/perlbrew/perls/perl-5.32.0-threads/lib/site_perl/5.32.0/DBD/CSV.pm line 410.
DBD::CSV::Table::push_row(DBD::CSV::Table=HASH(0x5587daf78350), DBI::st=HASH(0x5587da2cb1d0), ARRAY(0x5587da36b3d0)) called at /home/ba01m/perl5/perlbrew/perls/perl-5.32.0-threads/lib/site_perl/5.32.0/SQL/Statement.pm line 232
SQL::Statement::CREATE(DBD::CSV::Statement=HASH(0x5587da2cb230), DBI::st=HASH(0x5587da2cb1d0), ARRAY(0x5587daff92d8)) called at /home/ba01m/perl5/perlbrew/perls/perl-5.32.0-threads/lib/site_perl/5.32.0/SQL/Statement.pm line 157
SQL::Statement::execute(DBD::CSV::Statement=HASH(0x5587da2cb230), DBI::st=HASH(0x5587da2cb1d0), ARRAY(0x5587daff92d8)) called at /home/ba01m/perl5/perlbrew/perls/perl-5.32.0-threads/lib/site_perl/5.32.0/x86_64-linux-thread-multi/DBI/DBD/SqlEngine.pm line 1271
eval {...} called at /home/ba01m/perl5/perlbrew/perls/perl-5.32.0-threads/lib/site_perl/5.32.0/x86_64-linux-thread-multi/DBI/DBD/SqlEngine.pm line 1269
DBI::DBD::SqlEngine::st::execute(DBI::st=HASH(0x5587da2cb1d0)) called at /home/ba01m/perl5/perlbrew/perls/perl-5.32.0-threads/lib/site_perl/5.32.0/x86_64-linux-thread-multi/DBI.pm line 1635
DBD::_::db::do(DBI::db=HASH(0x5587daf77c38), "CREATE TABLE foo (id INTEGER, name CHAR (10))") called at wtf2.pl line 11
Can someone help, please?
Forwarding an issue mailed in private:
Most SQL bases either requires or permits ; following a statement. Not so for DBD::CSV.
That seems like a bug, because that makes it harder to switch to DBD::CSV.
Works:
$dbh->do ("CREATE TABLE foo (id INTEGER, name CHAR (10))");
Fails:
$dbh->do ("CREATE TABLE foo (id INTEGER, name CHAR (10));");
The second works fine for SQLite, MySQL and PostgreSQL.
Although I could not figure out why the csv_ prefix seems to be mandatory for the eol attribute, if used inside the csv_tables hash ref.
Does not work. Uses the default "\r\n" instead of "\n" only.
csv_tables => {
my_table => {
eol => "\n"
}
}
Works
csv_tables => {
my_table => {
csv_eol => "\n"
}
}
This was raised and reproduced on dbi-users, thanks @ronsavage.
I've written a further test for this which is more simple and passes far less options to connect()
to aid in identification of the cause and could possibly be made subject of a pull request.
DBD::CSV::Table::DESTROY
uncommenting this stops the warnings.csv_tables
is a sure way to trigger the warning, however I have seen multiple warnings from this code, from the test_with_options() for (1 .. 100);
calls, so I doubt this is the full story.Text::CSV_XS
object, so I don't know if the bug lies there - csv_tables
is not an option to new()
there though.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.