[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Library for investigating database schemas?

mlanza

8/19/2007 10:58:00 PM

I'm wondering what libraries are available for accessing the most
comprehensive information for a database schema. In particular, I want
information on:

* columns per table
* foreign keys
* column constraints (uniqueness, etc.)
* indexes

I am not sure if this information is accessible via ActiveRecord (some
is regarding the columns) or via DBI.

I will be using a MySQL database (and have heard about
http://www.tmtm.org/en/m...), but I would rather work with a
generic library providing a standard API that is database agnostic.
Also, I know I can get to this information by querying the database
INFORMATION_SCHEMA directly, but, again, I would rather the library be
oblivious to the underlying database and simply provide the schema
information.

Does such a library exist?

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

2 Answers

mlanza

8/20/2007 1:46:00 AM

0

I think I've uncovered some ways to do this. If there's a better way,
please say so:

> * columns per table

pp Person.columns

> * foreign keys

pp Person.reflections (not per the database itself but per ActiveRecord)

> * column constraints (uniqueness, etc.)

??

> * indexes

pp ActiveRecord::Base.connection.indexes('people')


Is there a one-stop library for gathering all this info.? Right now,
what I'm doing is sort of a mish-mash.

Clifford Heath

8/23/2007 4:43:00 AM

0

Mario T. Lanza wrote:
> I'm wondering what libraries are available for accessing the most
> comprehensive information for a database schema.

As you found, ActiveRecord already fetches column names. The extra
features you've asked for are variously implemented in gems, in
particular composite keys, magic models and DrySQL.

Clifford Heath.