Hi monks I have read some tutorials on SQLite and i have tried to do some work with it. My code is below:
$v = 0; # The v variable will now be used with the database my $dbh = DBI->connect( "dbi:SQLite:dbname=mydatabase.db", "", "" )|| + die "Cannot connect: DBI"; # If the file exists delete the information in it eval { local $dbh->{PrintError} = 0; $dbh->do("DROP TABLE webpages_data"); }; # Create a table $dbh->do( "CREATE TABLE webpages_data (id INTEGER PRIMARY KEY, page, +text, bigr)"); my $a = 1; while(@links) { $dbh->do( "INSERT INTO webpages_data VALUES('$a', '$_', '$text[$v +]', NULL)"); $a++; $v++; } # Disconnect when finished using the database $dbh->disconnect();

I have an array @text so the $v variable is to get the string inside each element of array and try to put it in the database table. The $a variable is to give a unique ID to each row in the table. These two variables work by adding to them 1 every time the loop is due to start again. I also want to keep the 4th column with a NULL value

The problem is i get an error "Use of uninitialized value in concatenation (.) or string". This comes from the INSERT INTO line. I have found previous posts that had this error but none of the solutions seem to help with this situation.

I have also downloaded the SQLite analyser program to see what is in my table but it doesn't bring up anything so i presume the information doesn;t get written in the database file

Any ideas? Thanks


In reply to How do I write data in SQLite by lampros21_7

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.