table_info is supposed to be the most portable eventually, it is currently experimental, and very few drivers implement it.

You guys should really investigate "Statement Handle Attributes" in the DBI pod. Even those depend on the underlying driver, but since they've been a part of DBI longer, they are more portable.

I recently started using DBD-SQLite, and after converting my mysql-specific sql into equivalent ANSI92 DBD-SQLite compliant using code from Re: MySQL 2 SQLite, I came up with the following to dump some metadata about my database ;)

use DBI; use Data::Dumper; my $dbh = DBI->connect("dbi:SQLite:pod.wiki.sqlite.db") or die $DBD::e +rr; warn "database name is ", $dbh->{Name}; my $sth = $dbh->prepare("SELECT * FROM content limit 0"); warn $sth->execute; for my $attr( qw[ NUM_OF_PARAMS NUM_OF_FIELDS NAME NAME_hash TYPE PRECISION SCALE NULLABLE]){ eval { warn $attr, ' ', Dumper($sth->{$attr}); }; warn $attr,' is unavailable (', 1||$@, ')' if $@; } __END__ database name is pod.wiki.sqlite.db at dbi.table.info.pl line 5. 3 at dbi.table.info.pl line 7. NUM_OF_PARAMS $VAR1 = 0; NUM_OF_FIELDS $VAR1 = 5; NAME $VAR1 = [ 'name', 'version', 'text', 'modified', 'comment' ]; NAME_hash $VAR1 = { 'text' => 2, 'modified' => 3, 'comment' => 4, 'version' => 1, 'name' => 0 }; TYPE is unavailable (1) at dbi.table.info.pl line 11. PRECISION is unavailable (1) at dbi.table.info.pl line 11. SCALE is unavailable (1) at dbi.table.info.pl line 11. NULLABLE is unavailable (1) at dbi.table.info.pl line 11.
update: ++ That is all true, but if you're looking for a list of tables, soon you'll be looking to describe those tables, and ... you get the point, yes? yes ;)


MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
** The Third rule of perl club is a statement of fact: pod is sexy.


In reply to Re: Re: my first database by PodMaster
in thread my first database by Anonymous Monk

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.