Extracting information back out of a DBH
simon at thegestalt.org
Mon Feb 9 21:01:00 GMT 2009
I'm dealing with some code that currently uses a lookup table for dbh
handles with the hash key being based on the dsn, username and password
I'm adapting it to be able to take in a random DB handle and therefore
I'd really like to be able to extract the dsn and username back out
again. Preferably I'd like to be able to get the password out again to
but I can't think of a database whereby a user can use multiple
passwords with the resulting handles having different abilities
(although maybe I'm wrong).
DBH has a clone method which "duplicates the $dbh connection by
connecting with the same parameters ($dsn, $user, $password) as
which sounds like it should mean that the information is available but
since it also does something with a closure it's possible that for .xs
based drivers something more funky is going on.
So basically, I have 3 questions:
1) Is there any reason not just to use the username and dsn in the hash
2) Is there any way to get that information out of a dbh
3) Is there another way to do this?
I suppose, I could either force the user to pass in a username and dsn
when they pass in the dbh or, alternatively, just use a random hash and
lose the auto pooling of handles.
More information about the london.pm