[CDBI] using different DSNs for reads/writes
Michael G Schwern
schwern at pobox.com
Thu Dec 20 00:09:54 GMT 2007
Aaron Wolfe wrote:
> I am converting some messy scripts I wrote to use the very nice Class
> DBI interface. I have run into a wall that I can't seem to figure out
> (please forgive me if this is easy and I am just ignorant).
> I have multiple sites running mysql using master -> slave replication.
> This means all changes to the data must happen at the master.
> However, lookups should always use the local copy. The master db is
> slow to query, but writes are very infrequent compared to reads so it
> works ok. In my current code, I just have two db handles and pick the
> correct one to use by hand.
> Is there a way to create a dbi class that would be smart enough to do
> selects from the local db, but updates and inserts to the master?
I could have sworn there were separate "read" vs "write" database handles
because I've dealt with this sort of problem before both to handle your issue
with master/slave databases and also to just have a separate "reader" database
user with lowered permissions to tighten security. But I can't seem to find it.
But there's no sense crying over every mistake.
You just keep on trying till you run out of cake.
-- Jonathan Coulton, "Still Alive"
More information about the ClassDBI