ilm...@ilmari.org (Dagfinn Ilmari Mannsåker) writes: > Alberto Luaces <alua...@udc.es> writes: > >> Hi, >> >> I stumped over a problem when learning to use DBIx::Class. I had a typo >> on the filename holding the database, but no exception was thrown until >> I wanted to retrieve some results, which was not intuitive for me. How >> do you check for a successful connection? > > First of all, you never need to do "or die ..." with DBIx::Class > operations, since they always throw exceptions on error. >
Ok. I was just trying after realizing no exception was happening. Actually I was using the autodie module in the beginning. > > Sencondly, DBIx::Class only hits the database when it absolutely has >to, > e.g. to fetch restults. This includes the initial connection. However, > you can force it to connect early by calling > > $schema->storage->ensure_connected; > > Which will throw an exception if it fails to connect. Yes, it sounds sensible for an ORM to be lazy, but I did not imagine that it could even involve connections. Thanks a lot for the pointer. -- Alberto _______________________________________________ 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