add distro files
[p5sagit/Devel-REPL.git] / examples / dbic_project_profile.pl
diff --git a/examples/dbic_project_profile.pl b/examples/dbic_project_profile.pl
new file mode 100644 (file)
index 0000000..8a97348
--- /dev/null
@@ -0,0 +1,16 @@
+# this might live in /path/to/checkout/.re.pl/project.rc
+# see: http://chainsawblues.vox.com/library/post/develrepl-part-4---script-options-rc-files-profiles-and-packaging.html
+
+# load my global ~/.re.pl/repl.rc
+Devel::REPL::Script->current->load_rcfile('repl.rc');
+
+use lib 'lib'; # to get at the lib/Project.pm, lib/Project/* perl modules
+use Project::Schema; # load the DBIC schema
+
+Project::Schema->connection('dbi:Pg:dbname=project_matthewt_test','matthewt',''); # connect to db
+Project::Schema->stacktrace(1); # turn on stack traces for DBI errors
+
+sub schema { 'Project::Schema' } # shortcut so things like schema->sources works
+sub rs { Project::Schema->resultset(shift); } # shortcut so rs('Foo')->find(1); works
+sub cols { Project::Schema->source(shift)->columns; } # cols('Foo') returns a column list
+