Hi, I spent some time reading documentation about DBIC Schema Loader and DBIC in general (hard stuff for newcomers to DBIC...) and wrote a little program that uses Schema Loader to load the schema of a little SQLite test database.
I found out how to get one of the metadata information I am interested in, namely foreign keys, the constrained columns, the referenced tables and the referenced columns. But I am quite sure this is not the way one should do it since I am digging bits of information out of a data structure I get when calling a method whose name starts with an underscore... Here is what I did: ... use DBIx::Class::Schema::Loader qw/ make_schema_at /; my $dsn = 'dbi:SQLite:./testdb'; make_schema_at( 'My::Schema', { debug => 0, dump_directory => './lib', }, [ $dsn, '', '' ], ); my $schema = My::Schema->connect( $dsn, '', '', '' ); my @relationships = $schema->source('T')->_relationships(); ... @relationships in my case looks as follows: 0 HASH(0x261359c) 'ss' => HASH(0x3c6eef4) 'attrs' => HASH(0x3c6c884) 'accessor' => 'multi' 'cascade_copy' => 0 'cascade_delete' => 0 'join_type' => 'LEFT' 'class' => 'My::Schema::Result::S' 'cond' => HASH(0x3c6926c) 'foreign.r1' => 'self.i' 'foreign.r2' => 'self.j' 'source' => 'My::Schema::Result::S' 'u' => HASH(0x3bfe16c) 'attrs' => HASH(0x3bfb69c) 'accessor' => 'filter' 'is_deferrable' => 0 'is_foreign_key_constraint' => 1 'join_type' => 'LEFT' 'on_delete' => 'NO ACTION' 'on_update' => 'NO ACTION' 'undef_on_null_fk' => 1 'class' => 'My::Schema::Result::A' 'cond' => HASH(0x3bfdd8c) 'foreign.u' => 'self.u' 'source' => 'My::Schema::Result::A' So I could pick out some of the information I am looking after. I am sure you can show me a better way to do this. Best regards José ----- Ursprüngliche Nachricht ----- Von: fREW Schmidt Gesendet: 30.10.12 03:29 Uhr An: DBIx::Class user and developer list Betreff: Re: [Dbix-class] DBIx-Table-TestDataGenerator-0.001 released If you were willing to use DBIC and DBIC Schema Loader instead of raw DBI you could support All The Databases. :) On Oct 29, 2012 5:01 PM, José Diaz Seng <josediazs...@gmx.de> wrote: Hi, yesterday I have released the initial version of DBIx::Table::TestDataGenerator, see http://search.cpan.org/~jds/DBIx-Table-TestDataGenerator-0.001/ Its goal is to support testing database clients by adding test data to tables. The main features are the automatic handling of table constraints and dealing with parent child relations in tables. Currently Oracle, PostgreSQL and SQLite are supported, additional DBMSs are in the works. It has already been a real pleasure discussing things with the Perl community, I want to say a big thank you to all people involved, for detailed acknowledgements (and everything else) please see the README file. Hopefully the module will be useful to you. I am eagerly awaiting your comments, critique and feature requests! To all affected by the hurricane reaching the East Coast right now I hope it will not be half as bad as feared, good luck! Best regards José _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk