Skip to content
Snippets Groups Projects
Commit 8d6aca93 authored by Leo Gordon's avatar Leo Gordon
Browse files

an example of using SqlCmd

parent b7e0766e
No related branches found
No related tags found
No related merge requests found
# mini-pipeline for testing meta-parameter evaluation and SqlCmd in "external_db" mode
my $cvs_root_dir = $ENV{'HOME'}.'/work';
# family database connection parameters (our main database):
my $pipeline_db = {
-host => 'compara3',
-port => 3306,
-user => 'ensadmin',
-pass => 'ensembl',
-dbname => "lg4_test_sqlcmd",
};
my $slave_db = {
-host => 'compara3',
-port => 3306,
-user => 'ensadmin',
-pass => 'ensembl',
-dbname => "lg4_test_sqlcmd_slave",
};
return {
# pass connection parameters into the pipeline initialization script to create adaptors:
-pipeline_db => $pipeline_db,
# shell commands that create and pre-fill the pipeline database:
-pipeline_create_commands => [
'mysql '.dbconn_2_mysql($pipeline_db, 0)." -e 'CREATE DATABASE $pipeline_db->{-dbname}'",
'mysql '.dbconn_2_mysql($pipeline_db, 1)." <$cvs_root_dir/ensembl-hive/sql/tables.sql",
'mysql '.dbconn_2_mysql($pipeline_db, 1)." <$cvs_root_dir/ensembl-hive/sql/procedures.sql",
'mysql '.dbconn_2_mysql($pipeline_db, 0)." -e 'CREATE DATABASE $slave_db->{-dbname}'",
],
-pipeline_wide_parameters => { # these parameter values are visible to all analyses, can be overridden by parameters{} and input_id{}
'db_conn' => $slave_db, # testing the stringification of a structure here
},
-resource_classes => {
0 => { -desc => 'default, 8h', 'LSF' => '' },
1 => { -desc => 'urgent', 'LSF' => '-q yesterday' },
},
-pipeline_analyses => [
{ -logic_name => 'create_table',
-module => 'Bio::EnsEMBL::Hive::RunnableDB::SqlCmd',
-parameters => { },
-hive_capacity => 20, # to enable parallel branches
-input_ids => [
{ 'sql' => 'CREATE TABLE distance (place_from char(40) NOT NULL, place_to char(40) NOT NULL, miles float, PRIMARY KEY (place_from, place_to))', },
],
-rc_id => 1,
},
{ -logic_name => 'fill_in_table',
-module => 'Bio::EnsEMBL::Hive::RunnableDB::SqlCmd',
-parameters => {
'sql' => [ "INSERT INTO distance (place_from, place_to, miles) VALUES ('#from#', '#to#', #miles#)",
"INSERT INTO distance (place_from, place_to, miles) VALUES ('#to#', '#from#', #miles#)", ],
},
-hive_capacity => 20, # to enable parallel branches
-input_ids => [
{ 'from' => 'Cambridge', 'to' => 'Ely', 'miles' => 18.3 },
{ 'from' => 'London', 'to' => 'Cambridge', 'miles' => 60 },
],
-wait_for => 'create_table',
-rc_id => 1,
},
],
};
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment