Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
4aed1a4c
Commit
4aed1a4c
authored
14 years ago
by
Andreas Kusalananda Kähäri
Browse files
Options
Downloads
Patches
Plain Diff
Be smarter.
parent
bd846555
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc-scripts/production_database/scripts/update_database_list.pl
+53
-59
53 additions, 59 deletions
...ripts/production_database/scripts/update_database_list.pl
with
53 additions
and
59 deletions
misc-scripts/production_database/scripts/update_database_list.pl
+
53
−
59
View file @
4aed1a4c
...
...
@@ -84,6 +84,8 @@ if ( !GetOptions( 'release|r=i' => \$release,
}
my
%species
;
my
%databases
;
my
%existing_databases
;
{
my
$dsn
=
sprintf
(
'
DBI:mysql:host=%s;port=%d;database=%s
',
...
...
@@ -91,28 +93,42 @@ my %species;
my
$dbh
=
DBI
->
connect
(
$dsn
,
$dbuser
,
$dbpass
,
{
'
PrintError
'
=>
1
,
'
RaiseError
'
=>
1
}
);
my
$statement
=
'
SELECT species_id, web_name, db_name
'
.
'
FROM species
'
.
'
WHERE is_current = 1
';
{
my
$statement
=
'
SELECT species_id, web_name, db_name
'
.
'
FROM species
'
.
'
WHERE is_current = 1
';
my
$sth
=
$dbh
->
prepare
(
$statement
);
$sth
->
execute
();
my
$sth
=
$dbh
->
prepare
(
$statement
);
$sth
->
execute
();
my
(
$species_id
,
$web_name
,
$db_name
);
$sth
->
bind_columns
(
\
(
$species_id
,
$web_name
,
$db_name
)
);
my
(
$species_id
,
$web_name
,
$db_name
);
$sth
->
bind_columns
(
\
(
$species_id
,
$web_name
,
$db_name
)
);
while
(
$sth
->
fetch
()
)
{
$species
{
$db_name
}
=
{
'
species_id
'
=>
$species_id
,
'
db_name
'
=>
$db_name
,
'
web_name
'
=>
$web_name
};
while
(
$sth
->
fetch
()
)
{
$species
{
$db_name
}
=
{
'
species_id
'
=>
$species_id
,
'
db_name
'
=>
$db_name
,
'
web_name
'
=>
$web_name
};
}
}
{
my
$statement
=
'
SELECT full_db_name FROM db_list
';
my
$sth
=
$dbh
->
prepare
(
$statement
);
$sth
->
execute
();
my
$database
;
$sth
->
bind_col
(
1
,
\
$database
);
while
(
$sth
->
fetch
()
)
{
$existing_databases
{
$database
}
=
1
;
}
}
$dbh
->
disconnect
();
}
my
%databases
;
foreach
my
$server
(
@servers
)
{
my
$dsn
=
sprintf
(
'
DBI:mysql:host=%s;port=%d
',
$server
,
$dbport
);
my
$dbh
=
DBI
->
connect
(
$dsn
,
$dbuser
,
$dbpass
,
...
...
@@ -125,14 +141,17 @@ foreach my $server (@servers) {
foreach
my
$species
(
keys
(
%species
)
)
{
$sth
->
bind_param
(
1
,
sprintf
(
'
%s%%\_%d\_%%
',
$species
,
$release
),
SQL_VARCHAR
);
$sth
->
execute
();
my
$database
;
$sth
->
bind_col
(
1
,
\
$database
);
while
(
$sth
->
fetch
()
)
{
if
(
exists
(
$existing_databases
{
$database
}
)
)
{
printf
(
"
Skipping '%s'
\n
",
$database
);
next
;
}
my
(
$db_type
,
$db_assembly
,
$db_suffix
)
=
(
$database
=~
/^[a-z]+_[a-z]+_([a-z]+)_[0-9]+_([0-9]+)([a-z]?)$/
);
...
...
@@ -157,60 +176,35 @@ foreach my $server (@servers) {
}
## end foreach my $server (@servers)
if
(
scalar
(
keys
(
%databases
)
)
==
0
)
{
die
(
sprintf
(
"
Did not find any databases for release %d
\n
",
$release
)
);
}
{
printf
(
"
Did not find any new databases for release %d
\n
",
$release
);
}
else
{
my
$dsn
=
sprintf
(
'
DBI:mysql:host=%s;port=%d;database=%s
',
$master
,
$dbport
,
'
ensembl_production
'
);
my
$dbh
=
DBI
->
connect
(
$dsn
,
$dbwuser
,
$dbwpass
,
{
'
PrintError
'
=>
1
,
'
RaiseError
'
=>
1
}
);
my
$select_stmt
=
'
SELECT db_id FROM db_list WHERE full_db_name = ?
';
my
$select_sth
=
$dbh
->
prepare
(
$select_stmt
);
my
$insert_stmt
=
my
$statement
=
'
INSERT INTO db
'
.
'
(species_id, db_type, db_release, db_assembly, db_suffix, db_host)
'
.
'
VALUES (?, ?, ?, ?, ?, ?)
';
my
$
insert_
sth
=
$dbh
->
prepare
(
$
insert_stm
t
);
my
$sth
=
$dbh
->
prepare
(
$
statemen
t
);
foreach
my
$database
(
keys
(
%databases
)
)
{
$select_sth
->
bind_param
(
1
,
$database
,
SQL_VARCHAR
);
$select_sth
->
execute
();
my
$db_hash
=
$databases
{
$database
};
my
$db_id
;
$select_sth
->
bind_col
(
1
,
\
$db_id
);
printf
(
"
Inserting database '%s' into
"
.
"
the production database
\n
",
$database
);
my
$is_found
=
0
;
while
(
$select_sth
->
fetch
()
)
{
$is_found
=
1
;
last
;
}
$select_sth
->
finish
();
if
(
$is_found
)
{
# printf( "The database '%s' is already in "
# . "the production database (id %d)\n",
# $database, $db_id );
}
else
{
my
$db
=
$databases
{
$database
};
printf
(
"
Inserting database '%s' into
"
.
"
the production database
\n
",
$database
);
$insert_sth
->
bind_param
(
1
,
$db
->
{'
species_id
'},
SQL_INTEGER
);
$insert_sth
->
bind_param
(
2
,
$db
->
{'
db_type
'},
SQL_VARCHAR
);
$insert_sth
->
bind_param
(
3
,
$release
,
SQL_INTEGER
);
$insert_sth
->
bind_param
(
4
,
$db
->
{'
db_assembly
'},
SQL_INTEGER
);
$insert_sth
->
bind_param
(
5
,
$db
->
{'
db_suffix
'},
SQL_VARCHAR
);
$insert_sth
->
bind_param
(
6
,
$db
->
{'
db_host
'},
SQL_VARCHAR
);
$insert_sth
->
execute
();
}
}
## end foreach my $database ( keys...)
$sth
->
bind_param
(
1
,
$db_hash
->
{'
species_id
'},
SQL_INTEGER
);
$sth
->
bind_param
(
2
,
$db_hash
->
{'
db_type
'},
SQL_VARCHAR
);
$sth
->
bind_param
(
3
,
$release
,
SQL_INTEGER
);
$sth
->
bind_param
(
4
,
$db_hash
->
{'
db_assembly
'},
SQL_INTEGER
);
$sth
->
bind_param
(
5
,
$db_hash
->
{'
db_suffix
'},
SQL_VARCHAR
);
$sth
->
bind_param
(
6
,
$db_hash
->
{'
db_host
'},
SQL_VARCHAR
);
$sth
->
execute
();
}
$dbh
->
disconnect
();
}
}
## end else [ if ( scalar( keys(%databases...)))]
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment