Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^7: DB persistence framework for Perl Classes

by tadamec (Beadle)
on Oct 18, 2004 at 19:35 UTC ( [id://400295]=note: print w/replies, xml ) Need Help??


in reply to Re^6: DB persistence framework for Perl Classes
in thread DB persistence framework for Perl Classes

Are you saying that you want to update some objects and then commit some of your changes but not all of them?

Nope. Just plain old, simple transactions.

Say, for example, I'd like to update 10,000 records in a database from a command-line script and I'd also like to read/update one record at a time in a web page. Currently, I have two different Class::DBI ancestors to handle the one-off changes, and another to handle batching the mass updates into smaller chunks so the transaction logs in the database don't get hammered.

Some of my problems stem, I'm sure, from enforcing least-privilege at the database and application levels; my Apache database user has privileges to update a very limited set of tables and can read almost all the tables, where the command line processes can update most tables. The web user updates one record at a time, while the command line process almost always updates in large batches.

Class::DBI seems to get confused in the Apache environment if I have transactions enabled in the Web base class and I haven't figured out a way around this other than doing a $obj->dbi_commit() after every read. This is, in my opinion, really a Bad Idea, as you shouldn't commit a record that you haven't changed and probably don't have write access to begin with.

Replies are listed 'Best First'.
Re^8: DB persistence framework for Perl Classes
by perrin (Chancellor) on Oct 18, 2004 at 19:50 UTC
    Okay, it's not really clear to me why you're having trouble with the transactions. They aren't any different from vanilla DBI, and I use them after updating multiple records in the same way I would with straight DBI commands. Maybe you're using InnoDB and getting tricked by the confusing isolation level settings it uses? Many people have trouble with that. Data committed in one process can't be seen in other processes until they commit. I change the isolation level to something more like Oracle or Postgres to get around this.

    Anyway, you're more than welcome to bring the issue up on the Class::DBI mailing list, especially if you can give a more precise description of the symptoms you're seeing.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://400295]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-06-16 00:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.