Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
What I'm expecting is the output of:#!/usr/bin/perl use warnings; use strict; use Storable qw(freeze thaw); use DBI; my $dbh = DBI->connect("dbi:SQLite:dbname=/root/testlib.db","",""); my @books=( { 'ISBN' => '0596004788', 'Title' => 'Learning Perl Objects, References, and Mod +ules' }, { 'ISBN' => '0596001320', 'Title' => 'Learning Perl, Third Edition' }, { 'ISBN' => '0596003137', 'Title' => 'Perl Cookbook, Second Edition' }, ); my $book_list = freeze(\@books); $dbh->do("INSERT INTO BOOKS (BOOK) values (?)",undef,$book_list); my $sth = $dbh->prepare( 'select * from BOOKS' ); $sth->execute(); my $book= $sth->fetchrow_array ; my $new_list = thaw($book); foreach(@{$new_list}){ print "$_->{'ISBN'} $_->{'Title'}\n"; }
Instead nothing happens. At first I though the database migh be mangleing the data, so I recreated the table with: CREATE TABLE BOOKS(BOOK BLOB);. Which if my understanding, and execution is correct should allow data to be stored exactly as it was inserted? What I'm trying to do is slightly beyond my current abilites, and I'm stumped. I'll never learn if I don't try. Any help you could offer would be appreciated.0596004788 Learning Perl Objects, References, and Modules 0596001320 Learning Perl, Third Edition 0596003137 Perl Cookbook, Second Edition
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with storable and Sqlite
by antirice (Priest) on Nov 18, 2005 at 06:09 UTC | |
by Anonymous Monk on Nov 18, 2005 at 11:57 UTC | |
|
Re: Problems with storable and Sqlite
by friedo (Prior) on Nov 18, 2005 at 05:06 UTC | |
by Errto (Vicar) on Nov 18, 2005 at 05:13 UTC | |
|
Re: Problems with storable and Sqlite
by Aristotle (Chancellor) on Nov 18, 2005 at 12:20 UTC | |
|
Re: Problems with storable and Sqlite
by DrHyde (Prior) on Nov 18, 2005 at 11:16 UTC |