In other words, it holds the part after the driver indication in the DSN part. When e.g. connecting to CSV like

my $dbh = DBI->connect ("dbi:CSV:f_ext=.csv/r;f_encoding=utf-8", undef +, undef, { RaiseError => 1 });

The return values for $dbh->{Name} will be f_ext=.csv/r;f_encoding=utf-8, which might not be very useful information.

The fact the DBD::Pg in your case returns the correct database name, might be because you initiated the connection using something like

my $dbh = DBI->connect ("dbi:Pg:dbname=test", ...);

but when you connect using just "dbi:Pg:" in combination with the environment variable $PGDATABASE, you might not get anything useful at all

$ env PGDATABASE=merijn perl -MDBI -wE'say DBI->connect("dbi:Pg:")->{N +ame}||"not known"' not known $

Enjoy, Have FUN! H.Merijn

In reply to Re^3: DBI:how to get name of the db ? by Tux
in thread DBI:how to get name of the db ? by ansh batra

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.