sdyates has asked for the wisdom of the Perl Monks concerning the following question:
I think it has to do with how I am using perl to access the database. What is the best way to lock the tables, write/update the tables and then unlock. I only need to lock for write access, not read access.
Reading up on MySQL.com indicates the proper procedure, however, I may have my perl code in correct. Below is a snipett of my perl DB code without locking th talbes:
Use the below to open the db.
How do I properly integrate the locking of tables for write access when I am performing the write_db() routine?sub open_dbi { my $db_user = $DBuser; my $db_password = $DBpassword; my $DBName = 'db'; my $dbh = DSBI->connect("dbi:mysql:DBName:$IP","$db_user","db_passw +ord"; return $dbh; } This part writes the sql command to the table: sub write_db { $SQLCommand = "{SQL command}"; my $sth = $dbh->prepare("$SQLCommand"); $sth->execute; }
Please advise,
Simon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using perl to lock the tables in mysql
by dug (Chaplain) on Jan 02, 2002 at 20:47 UTC |