MorayJ has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI and sqlite concurrency
by RichardK (Parson) on Sep 15, 2015 at 17:36 UTC | |
by MorayJ (Beadle) on Sep 16, 2015 at 09:35 UTC | |
|
Re: DBI and sqlite concurrency
by poj (Abbot) on Sep 15, 2015 at 18:00 UTC | |
by MorayJ (Beadle) on Sep 16, 2015 at 09:40 UTC | |
|
Re: DBI and sqlite concurrency
by stevieb (Canon) on Sep 15, 2015 at 17:15 UTC | |
by MorayJ (Beadle) on Sep 16, 2015 at 09:39 UTC | |
|
Re: DBI and sqlite concurrency
by Your Mother (Archbishop) on Sep 16, 2015 at 22:35 UTC | |
|
Re: DBI and sqlite concurrency
by soonix (Chancellor) on Sep 16, 2015 at 07:50 UTC | |
by MorayJ (Beadle) on Sep 16, 2015 at 09:43 UTC | |
|
Re: DBI and sqlite concurrency
by locked_user sundialsvc4 (Abbot) on Sep 15, 2015 at 17:51 UTC | |
by MorayJ (Beadle) on Sep 16, 2015 at 09:47 UTC |