Hello monks, I'm new to Perl and I've been trying to write a script that will import a data file (XXX.out) into a table (XXX) in a SQLite databse, and
I would be very appreciative if someone could enlighten me please!
Everything was going great until I used
$db->do(".import XXX.out XXX);
which gave me this error:
DBD::SQLite::db do failed: near ".": syntax error(1) at dbdimp.c line 271 at ./new.pl line 13.
I tried using single quotes too, and backslashing the period, together and separately, but it didn't work. The
$db->do("create table XXX (@colnames)");
line earlier in the code worked just fine. Also, when I instead used the INSERT function
(i.e., $db->do("INSERT INTO XXX VALUES (@somevalues)");
to just insert a few lines, rather than using .import to import the file, it worked.
But somehow the .import function won't seem to work.
(I would just use INSERT, but looping through the file to insert line by line takes much longer than .import.)
(In fact the ".separator" function also gave me the same problem, but I changed the data file so that I wouldn't have to use .separator).
Furthermore, when I just go to sqlite myself and type .import XXX.out XXX
it imports the XXX.out file into the XXX table just fine!
So the problem seems not to lie with the XXX.out data file or the XXX table. But
somehow I just can't get it to work in my Perl script.
Can someone please shed some light on this? Thank you!
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.