Re: DBIx::DBH - Perl extension for simplifying database connections

From: Eric (ef_at_kwinternet.com)
Date: 12/01/04


Date: Wed, 01 Dec 2004 10:53:38 -0800
To: Tim Bunce <Tim.Bunce@pobox.com>

At 10:39 AM 12/1/2004, you wrote:
>On Wed, Dec 01, 2004 at 09:56:01AM -0500, John Siracusa wrote:
> > On Wed, 1 Dec 2004 09:46:24 +0000, Tim Bunce <tim.bunce@pobox.com> wrote:
> > > Do you generally pass URLs around as a string or broken up into a hash?
> >
> > If they had different formats for different consumers, I would. (And even
> > today, I use my own URI objects when I know I'll have to do any significant
> > amount of manipulation.)
> >
> > I think this module is definitely useful. I already store my DSNs in
> hashes
> > and assemble the pieces as necessary depending on the driver.
>
>Lots of people do, it seems, but I'm not getting much background about why.
>
>FWIW, the reason I'm digging here is because I agree there may be
>some value in the DBI supporting something along these lines, but
>I need a better understanding of the underlying issues. More real-
>world examples would help.
>
>It'll always come down to the issue of "why not store complete DSNs?"
>and so far that's not been well covered by the feedback I've got.

Hi,

In our case we have several databases in a replication line using mysql. In
some cases we might want to connect to a server other than the first in
line, but most often we connect to the first in line/master. I also wanted
to make sure that if the script happened to be running on the master local
host that it would not connect using the host name and end up using TCP on
localhost.

Does that make any sense? I am not sure now that I think about it why I
could not just store the DSN for everything, but only separate out the
hostname. But then that is all I am doing anyway.

+-------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+-------+
| dbname | varchar(40) | | PRI | | |
| dborder | tinyint(2) | YES | | NULL | |
| ip | varchar(15) | | MUL | 0 | |
| servername | varchar(100) | | PRI | | |
| username | varchar(20) | | | | |
| password | varchar(20) | | | | |
| raise_error | enum('1','0') | | | 1 | |
| autocommit | enum('1','0') | | | 1 | |
+-------------+---------------+------+-----+---------+-------+

I don't use the IP right now, but record it anyway. The server name is
important because I use the localhost name to match up with that, and if it
matches then don't add in the hostname to the connect string.

I just looked at DBIx::DBH and I have to say I don't get it. Why is that
any easier than the default?
I thought at first this thread was talking about managing connections..

Thanks,

Eric

>Tim.



Relevant Pages

  • Re: /bin/hostname
    ... Find a real news server. ... in /etc/hosts that maps the host and the FQDN to the static IP ... Linux distributions are supposed to follow Linux Standard Base standards, ... hostname -- show or set the system's host name ...
    (comp.os.linux.networking)
  • Re: (was Re: setting FQDN in /etc/hosts)
    ... There should be a space before the word localhost, ... the hostname command will tell you what ... 503 Leafnode must have a unique fully-qualified domain name. ... ## This is the NNTP server leafnode fetches its news from. ...
    (news.software.readers)
  • Re: DNS lookup delays
    ... > 127.0.0.1 localhost.localdomain localhost luminiferous luminiferous.aethernet ... You want to set your hostname, so the machine isn't trying to work it ... That sounds awfully like it's not using its own hosts file to work out ... >> to resolve them locally (via the hosts file, or your own DNS server). ...
    (linux.redhat.install)
  • RE: setting host name during install?
    ... statement hostname= to /etc/rc.conf. ... is to build a FBSD gateway server, the name of this PC should be ... registered domain name on the public Internet (unless of course it's ... gateway.fbsdjones.com is a very acceptable fake host name to use. ...
    (freebsd-questions)
  • Compiler matter
    ... I tried to compile a simple hello world C program but the compiler looked ... for the old host name. ... Cannot find the license server ... The lookup for the hostname on the SERVER line in the ...
    (comp.unix.solaris)