Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Scratch DB

by mje (Curate)
on Sep 30, 2011 at 08:18 UTC ( [id://928721]=note: print w/replies, xml ) Need Help??


in reply to Scratch DB

Nice one and thanks. I'm sure I'll find this useful.

BTW, on line 21 I had to add an argument to Term::Realine's constructor to make it work here - I just passed $0. According to http://search.cpan.org/~flora/perl-5.14.2/lib/Term/ReadLine.pm the constructor takes a string.

You also need a newish Text::CSV or you won't have getline_all (I had 1.17 and that did not have it).

Lastly, I notice the table name is optional and if I have a csv file called xxx.csv only containing something like

1,fred 2,dave 3,john

you seem to have to name the table or you get:

sdb> load xxx.csv DBD::SQLite::db prepare failed: unknown database xxx at /home/martin/b +in/scratch_db.pl line 56, <$fh> line 3. Can't call method "execute" on an undefined value at /home/martin/bin/ +scratch_db.pl line 56, <$fh> line 3.

Replies are listed 'Best First'.
Re^2: Scratch DB
by Fox (Pilgrim) on Sep 30, 2011 at 14:09 UTC
    BTW, on line 21 I had to add an argument to Term::Realine's constructor to make it work here - I just passed $0. According to http://search.cpan.org/~flora/perl-5.14.2/lib/Term/ReadLine.pm the constructor takes a string.
    Doh !, That doesn't happen with me ! I guess it is because, when available, Term::ReadLine uses Term::ReadLine::Gnu, and this one doesn't require the argument
    if I have a csv file called xxx.csv
    Uh oh, SQLite seems to interpret the dot as database.table, I guess the best option here is to strip the suffix of the file.

    Thanks for the feedback, I updated the script.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://928721]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 07:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found