#!/usr/bin/perl -w use strict; use Germinate::Schema; use Data::Dump qw(dump); use Time::Format qw(%time %strftime %manip); print "testing loading:\n"; # Connection parameters my $dsn = 'dbi:mysql:cpc'; my $usr = 'nelo'; my $psw = 'n'; # Create a database connection my $schema = Germinate::Schema->connect( $dsn, $usr, $psw ); do { print "connected to cpc database:\n"; # Provide phenotype name, short name and description my $unit = 1; my $name = 'phenotype test name'; my $short = 'PTN'; my $desc = 'a fictional phenotype to test loading the database.'; my $time = $time{'yyyy-mm-dd hh:mm:ss'}; # Insert new and unique phenotypes my $phenotype = $schema->resultset('Phenotypes')->find_or_create( { unit_id => $unit, phenotype_name => $name, phenotype_short_name => $short, description => $desc, created_on => $time, updated_on => $time, }, { key => 'my_key' } ); # SELECT * FROM phenotypes my $rs = $schema->resultset('Phenotypes')->search(); # Save phenotypes { name => id } in a hash my $phenotypes; while ( my $phe_name = $rs->next ) { $phenotypes->{$phe_name->phenotype_uid} = $phe_name->phenotype_name; } # Test print print dump( $phenotypes ), "\n"; } if ($schema); exit;