![]() |
![]()
| ![]() |
![]()
NAMEBio::MAGETAB::Util::DBLoader - A persistent storage class used to track Bio::MAGETAB object creation and insertion into a relational database. SYNOPSISrequire Bio::MAGETAB::Util::Reader; require Bio::MAGETAB::Util::Persistence; require Bio::MAGETAB::Util::DBLoader; my $reader = Bio::MAGETAB::Util::Reader->new({ idf => $idf }); my $db = Bio::MAGETAB::Util::Persistence->new({ dbparams => ["dbi:SQLite:$db_file"], }); # If this is a new database, deploy the schema. unless ( -e $db_file ) { $db->deploy(); } # Connect to the database. $db->connect(); my $builder = Bio::MAGETAB::Util::DBLoader->new({ database => $db, }); $reader->set_builder( $builder ); # Read objects into the database. $reader->parse(); DESCRIPTIONDBLoader is a Builder subclass which uses a relational database backend to track object creation, rather than the simple hash reference mechanism used by Builder. See the Persistence class and the Tangram module documentation for more information on supported database engines. ATTRIBUTESSee the Builder class for documentation on the superclass attributes.
METHODSSee the Builder class for documentation on the superclass methods. CAVEATSObjects when modified are not automatically updated in the database. You should use the "update" method to do this (see METHODS in the Builder class). In particular, it is important to bear in mind that there are places in the Bio::MAGETAB model where relationships between objects are being maintained behind the scenes (this allows certain relationships to be navigable in both directions). When modifying these objects, you must also call "update" on their target objects to ensure the database is kept synchronized with the objects held in memory. For example: # SDRFRow to Nodes is a reciprocal relationship: my $row = $loader->create_sdrf_row({ nodes => \@nodes, }); # @nodes now know about $row, but the database doesn't know this: $loader->update( @nodes ); # Similarly, with Edges and Nodes: my $edge = $loader->find_or_create_edge({ inputNode => $in, outputNode => $out, }); # Again, $in and $out know about $edge, but the database does not: $loader->update( $in, $out ); KNOWN BUGSWhen used with SQLite or MySQL (and possibly others), the Tangram modules incorrectly modify any "select" statements containing the '%' character, so that this character is replaced with '%%'. This means that while values are correctly inserted into the database they are not retrieved correctly, and this may result in errors or duplicate entries when working with objects whose identifying fields contains a '%' character. See the Builder class for a discussion on object identity, and <http://rt.cpan.org/Public/Bug/Display.html?id=29133> for a possible quick fix for this Tangram bug. SEE ALSOBio::MAGETAB::Util::Reader Bio::MAGETAB::Util::Builder Bio::MAGETAB::Util::Persistence AUTHORTim F. Rayner <tfrayner@gmail.com> LICENSEThis library is released under version 2 of the GNU General Public License (GPL).
|