On Jun 15, 2007, at 6:40 PM, Jeffrey Horn wrote: > I'm wondering if there's any code out there that will generate > Rose::DB::Object's for all tables in a database. I have my own > makeshift > version which will do it for a given table, and the loop to simply > iterate > through tables isn't bad. I'm wondering if there's something that > will > create all the FK mappings for me, which would probably imply that > it would > also do some sort of DAG analysis on the table dependencies. > > Any help in that direction would be appreciated! > > Thanks!
see below! it can take some time to work ############################################## use warnings; use strict; package MyApp::RoseDB; use Rose::DB (); use base qw(Rose::DB); __PACKAGE__->use_private_registry; __PACKAGE__->default_domain('main'); __PACKAGE__->default_type('main'); __PACKAGE__->register_db( domain => 'main', type => 'main', driver => 'Pg', database => 'myapp', host => 'localhost', username => 'myapp', password => 'myapp', ); ############################################### package MyApp::RoseDB::Object; use base qw(Rose::DB::Object); sub init_db { MyApp::RoseDB->new }; ############################################### package main; use Rose::DB::Object::Loader; my $loader= Rose::DB::Object::Loader->new( db=> MyApp::RoseDB->new('main'), class_prefix=> 'MyApp::RoseDB::Object' ); $loader->make_modules( module_dir=> '/rose', with_foreign_keys=> 1, with_relationships=> 1 ); ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object