Library for investigating database schemas?

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
MySQL/Ruby), 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

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.

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 H…