lampros21_7 has asked for the wisdom of the Perl Monks concerning the following question:
$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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I write data in SQLite
by jZed (Prior) on Feb 03, 2006 at 23:55 UTC | |
|
Re: How do I write data in SQLite
by Joost (Canon) on Feb 03, 2006 at 23:37 UTC | |
by lampros21_7 (Scribe) on Feb 03, 2006 at 23:42 UTC | |
by Joost (Canon) on Feb 03, 2006 at 23:45 UTC | |
by lampros21_7 (Scribe) on Feb 03, 2006 at 23:59 UTC | |
|
Re: How do I write data in SQLite
by GhodMode (Pilgrim) on Feb 04, 2006 at 00:00 UTC | |
by chromatic (Archbishop) on Feb 04, 2006 at 03:56 UTC | |
by lampros21_7 (Scribe) on Feb 04, 2006 at 00:58 UTC | |
|
Re: How do I write data in SQLite
by chargrill (Parson) on Feb 04, 2006 at 00:56 UTC |