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.
In reply to Re: Scratch DB
by mje
in thread Scratch DB
by Fox
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.