[CDBI] using different DSNs for reads/writes

Aaron Wolfe aawolfe at gmail.com
Wed Dec 19 19:36:17 GMT 2007


Hi,

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
read the "multiple databases" section in the wiki but in addition to
being a bit over my head, I don't think they address splitting reads
vs writes, just using multiple connections to identical dbs.

Thanks for advice,
-Aaron



More information about the ClassDBI mailing list