Hello, I am trying to write a simple perl program (perl version 5.16.3). I am accessing a SQLite db using WAL. It took me a while but I learned that my connection is only looking at the DB file and not the WAL file. As a result, my queries are not returning the full data set.

the SQLite firefox addon shows 10 invoices in the invoice table. the following program is returning only 8...

use DBD::SQLite; use DBI; use Tkx; use File::Copy; use PDF::API2; use constant mm => 25.4 / 72; use constant in => 1 / 72; use constant pt => 1; # Prompt user for database file location $dbfile = Tkx::tk___getOpenFile(-initialdir=>'C:/events_p', -title=>'P +lease select your current events database file (event.sqlite)'); $dbfile =~ s/\//\\/g; # Initialiatize path variables # parse out the db filename and path $DbFilename=substr($dbfile,length($dbfile)-12,12); $FolderPath=substr($dbfile,0,length($dbfile)-13); $OriginalImages_Path=$FolderPath."\\OriginalImages"; $Internal_Path=$FolderPath."\\_internal"; $Carts_Path=$FolderPath."\\Carts"; $Orders_Path=$FolderPath."\\Orders"; $favorites="c:\favorites"; $Invoices_Folder="C:\\events_p_invoices"; # Error and exit if incorrect DB filename was selected if ($DbFilename ne 'event.sqlite') { print "\n**** ERROR ****, Invalid Database Filename Selected\n"; print " You MUST select the filename called event.sqlite\n"; + sleep(10); exit; } # Connect to the Database my $dbh2 = DBI->connect("dbi:SQLite:$dbfile", "", "",{RaiseError => 1, + AutoCommit => 1}) or die $DBI::errstr;; $dbh2->do('PRAGMA journal_mode=WAL'); my $sth = $dbh2->prepare("SELECT count(*) fromInvoice"); $sth->execute(); while (@data = $sth->fetchrow_array()) { print "count=$data[0]\n"; } exit;

If I go into the firefox add on and run a checkpoint , the 2 new invoices get flushed from the WL to the db file and then my program sees them
what am I doing wrong where my script is only looking at the db file and not the WAL file?

thanks!

John


In reply to dbd:sqlite and WAL files by johnpat12

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.