[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Getting MySQL column comment metadata?

mlanza

8/19/2007 2:34:00 PM

Hi All,

How do I go about getting the "Comments" metadata--the one I type via
MySQL Administrator, for example--associated with a MySQL column?

I have been able to pull metadata from both ActiveRecord and DBI but
cannot seem to find this added bit of info.

Thanks.
Mario T. Lanza
--
Posted via http://www.ruby-....

4 Answers

Michael Steinfeld

8/19/2007 3:19:00 PM

0

I'm not sure what you are asking, so I will take a guess...

If you want to access the metadata on all tables in db "MY_DB" you can
do something like..

SELECT table_name, table_type, engine FROM INFORMATION_SCHEMA.tables
WHERE table_schema = 'MY_DB' ORDER BY table_type ASC, table_name DESC;

Or you can just use "describe table_name;" to get data on that specific table.

-mike

On 8/19/07, Mario T. Lanza <mlanza@comcast.net> wrote:
> Hi All,
>
> How do I go about getting the "Comments" metadata--the one I type via
> MySQL Administrator, for example--associated with a MySQL column?
>
> I have been able to pull metadata from both ActiveRecord and DBI but
> cannot seem to find this added bit of info.
>
> Thanks.
> Mario T. Lanza
> --
> Posted via http://www.ruby-....
>
>


--
Michael Steinfeld
Linux Admin/Developer
AIM: mikesteinfeld
GTALK: mikeisgreat@gmail.com

Ken Bloom

8/19/2007 4:42:00 PM

0

On Sun, 19 Aug 2007 23:33:35 +0900, Mario T. Lanza wrote:

> Hi All,
>
> How do I go about getting the "Comments" metadata--the one I type via
> MySQL Administrator, for example--associated with a MySQL column?
>
> I have been able to pull metadata from both ActiveRecord and DBI but
> cannot seem to find this added bit of info.

This doesn't appear to be implemented directily in MySQL's C API.
Certainly it's not implemented in the direct MySQL Ruby API (see http://
www.tmtm.org/en/mysql/ruby/ and have a look at fetch_fields and the
Mysql::Field class). Since DBD::Myql uses fetch_fields to determine what
metadata is available, it's not available in dbi. I don't know about
ActiveRecord, but I would expect the same thing.

The only way I know of to get this information is by running a "show full
columns from TABLENAME" or using INFORMATION_SCHEMA. (Well, there's "show
create table" too, but that requires parsing -- why use that when you
have "show full columns")

--Ken

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...

mlanza

8/19/2007 11:01:00 PM

0

Thanks for the help. This is useful but I would like to use a library
designed for providing this sort of information without regard to the
underlying database. I attempted to clarify my original request, by
posting:

http://www.ruby-...topic/122...

Thanks again.
--
Posted via http://www.ruby-....

mlanza

8/20/2007 1:54:00 AM

0

The column I was referring to appears in the attached screenshot. Far
right. Notice "First name".



Attachments:
http://www.ruby-...attachment/130/Scre...

--
Posted via http://www.ruby-....