I'm not sure if DBI::table_info and DBI::column_info are a pipe dream or not.. From what I've seen around CPAN, any code that needs access to database schemas has employed DBD-specific code/queries for that purpose. I'd would be very interested to see examples of table_info and column_info that work transparently across many DBDs.

Here are queries you can execute to fetch info about columns and tables, for the drivers I know how:

MySQL: show tables describe TABLE_NAME SQLite: select name from sqlite_master where type='table' pragma table_info('TABLE_NAME')
You will also have better luck with table_info and column_info if you look at their usage in the DBI docs -- they return active statement handles, not a list of things. (The tables method does return a simple list, but your usage of it (no arguments) is deprecated -- also note that for many drivers, the tables method returns a lot of system tables, views, etc.. probably more than you want).

blokhead


In reply to Re: Column info request. by blokhead
in thread Column info request. by Nik

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.