Hello,

I have a query about my use of DBI and using it with sqlite3

I have the following code and wonder if anyone knows if it will be safe to use

I am wanting to get the rows from the database and then put them into another database (I lie - I'm putting them into a google spreadsheet)

Then I want to delete the data that I've put into the google spreadsheet from the original database

My worry is that, between me selecting and processing the records, someone may have added another row which I then delete without processing

What I'm hoping is that any additions will be queued up until I've disconnected and that there is not a window opened up between my selecting and deleting where someone would be allowed to add anything new

My question is: am I ok or am I asking for trouble?

Thanks for any light that can be shone on this

MorayJ

my $dbh = DBI->connect( # connect to your database, create if "dbi:SQLite:dbname=$dbfile", # DSN: dbi, driver, database file "", # no user "", # no password { RaiseError => 1 }, # complain if something goes wrong ) or die $DBI::errstr; my $search = $dbh->prepare('SELECT * FROM addresses '); my $delete = $dbh->prepare('DELETE FROM addresses'); my $rc = $search->execute or die $search->errstr; while ( my @row = $search->fetchrow_array() ) { print @row[0] . "\n"; }; my $rc2 = $delete->execute or die $sth->errstr; $dbh->disconnect;

In reply to DBI and sqlite concurrency by MorayJ

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.