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
38a39820
Commit
38a39820
authored
13 years ago
by
Leo Gordon
Browse files
Options
Downloads
Patches
Plain Diff
sqlite engine support added for eHive
parent
8b713994
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/Bio/EnsEMBL/DBSQL/AnalysisAdaptor.pm
+10
-31
10 additions, 31 deletions
modules/Bio/EnsEMBL/DBSQL/AnalysisAdaptor.pm
modules/Bio/EnsEMBL/DBSQL/DBConnection.pm
+62
-47
62 additions, 47 deletions
modules/Bio/EnsEMBL/DBSQL/DBConnection.pm
with
72 additions
and
78 deletions
modules/Bio/EnsEMBL/DBSQL/AnalysisAdaptor.pm
+
10
−
31
View file @
38a39820
...
...
@@ -355,6 +355,7 @@ sub store {
throw
("
Analysis cannot be stored without a valid logic_name
");
}
my
$insertion_method
=
(
lc
(
$self
->
dbc
->
driver
)
eq
'
sqlite
')
?
'
INSERT OR IGNORE
'
:
'
INSERT IGNORE
';
my
$rows_inserted
=
0
;
my
$sth
;
...
...
@@ -366,21 +367,10 @@ sub store {
# this record then there will not be a problem.
$sth
=
$self
->
prepare
(
q{
INSERT IGNORE INTO analysis
SET created = ?,
logic_name = ?,
db = ?,
db_version = ?,
db_file = ?,
program = ?,
program_version = ?,
program_file = ?,
parameters = ?,
module = ?,
module_version = ?,
gff_source = ?,
gff_feature = ?
qq{
$insertion_method INTO analysis
(created, logic_name, db, db_version, db_file, program, program_version, program_file, parameters, module, module_version, gff_source, gff_feature)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
}
);
$sth
->
bind_param
(
1
,
$analysis
->
created
(),
SQL_DATETIME
);
...
...
@@ -401,22 +391,11 @@ sub store {
}
else
{
$sth
=
$self
->
prepare
(
q{
INSERT IGNORE INTO analysis
SET created = now(),
logic_name = ?,
db = ?,
db_version = ?,
db_file = ?,
program = ?,
program_version = ?,
program_file = ?,
parameters = ?,
module = ?,
module_version = ?,
gff_source = ?,
gff_feature = ?
}
qq{
$insertion_method INTO analysis
(created, logic_name, db, db_version, db_file, program, program_version, program_file, parameters, module, module_version, gff_source, gff_feature)
VALUES (CURRENT_TIMESTAMP, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
}
);
$sth
->
bind_param
(
1
,
$analysis
->
logic_name
,
SQL_VARCHAR
);
...
...
This diff is collapsed.
Click to expand it.
modules/Bio/EnsEMBL/DBSQL/DBConnection.pm
+
62
−
47
View file @
38a39820
...
...
@@ -149,42 +149,43 @@ sub new {
throw
("
Cannot specify other arguments when -DBCONN argument used.
");
}
$self
->
dbname
(
$dbconn
->
dbname
());
$self
->
username
(
$dbconn
->
username
());
$self
->
driver
(
$dbconn
->
driver
());
$self
->
host
(
$dbconn
->
host
());
$self
->
password
(
$dbconn
->
password
());
$self
->
port
(
$dbconn
->
port
());
$self
->
driver
(
$dbconn
->
driver
());
$self
->
username
(
$dbconn
->
username
());
$self
->
password
(
$dbconn
->
password
());
$self
->
dbname
(
$dbconn
->
dbname
());
if
(
$dbconn
->
disconnect_when_inactive
())
{
$self
->
disconnect_when_inactive
(
1
);
}
}
else
{
$db
||
throw
("
-DBNAME argument is required.
");
$user
||
throw
("
-USER argument is required.
");
$db
||
throw
("
-DBNAME argument is required.
");
$driver
||=
'
mysql
';
$host
||=
'
mysql
';
if
(
!
defined
(
$port
)){
$port
=
3306
;
if
(
$host
eq
"
ensembldb.ensembl.org
"){
if
(
$db
=~
/\w+_\w+_\w+_(\d+)/
){
if
(
$
1
>=
48
){
$port
=
5306
;
}
}
}
if
(
$driver
eq
'
mysql
')
{
$user
||
throw
("
-USER argument is required.
");
$host
||=
'
mysql
';
if
(
!
defined
(
$port
)){
$port
=
3306
;
if
(
$host
eq
"
ensembldb.ensembl.org
"){
if
(
$db
=~
/\w+_\w+_\w+_(\d+)/
){
if
(
$
1
>=
48
){
$port
=
5306
;
}
}
}
}
}
$wait_timeout
||=
0
;
$self
->
username
(
$us
er
);
$self
->
driver
(
$driv
er
);
$self
->
host
(
$host
);
$self
->
dbname
(
$db
);
$self
->
password
(
$password
);
$self
->
port
(
$port
);
$self
->
driver
(
$driver
);
$self
->
username
(
$user
);
$self
->
password
(
$password
);
$self
->
dbname
(
$db
);
$self
->
timeout
(
$wait_timeout
);
if
(
$inactive_disconnect
)
{
...
...
@@ -272,6 +273,20 @@ sub connect {
}
);
};
}
elsif
(
lc
(
$self
->
driver
())
eq
'
sqlite
'
)
{
$dsn
=
sprintf
(
"
DBI:SQLite:%s
",
$self
->
dbname
()
);
eval
{
$dbh
=
DBI
->
connect
(
$dsn
,
'',
'',
{
'
RaiseError
'
=>
1
,
}
);
};
}
else
{
$dsn
=
sprintf
(
...
...
@@ -642,7 +657,7 @@ sub prepare {
throw
("
Attempting to prepare an empty SQL query.
");
}
#
print STDERR
"SQL(".$self->dbname."):" . join(' ', @args) . "\n";
#warn
"SQL(".$self->dbname."):" . join(' ', @args) . "\n";
my
$sth
=
$self
->
db_handle
->
prepare
(
@args
);
...
...
@@ -678,7 +693,7 @@ sub do {
throw
("
Attempting to do an empty SQL query.
");
}
#
info(
"SQL(".$self->dbname."):$string"
)
;
#
warn
"SQL(".$self->dbname."):
$string";
my
$result
=
$self
->
db_handle
->
do
(
$string
);
...
...
@@ -771,16 +786,16 @@ sub add_limit_clause{
my
$new_sql
=
'';
if
(
$self
->
driver
eq
'
mysql
'){
$new_sql
=
$sql
.
'
LIMIT
'
.
$max_number
;
$new_sql
=
$sql
.
'
LIMIT
'
.
$max_number
;
}
elsif
(
$self
->
driver
eq
'
odbc
'){
#need to get anything after the SELECT statement
$sql
=~
/select(.*)/i
;
$new_sql
=
'
SELECT TOP
'
.
$max_number
.
$
1
;
#need to get anything after the SELECT statement
$sql
=~
/select(.*)/i
;
$new_sql
=
'
SELECT TOP
'
.
$max_number
.
$
1
;
}
else
{
warning
("
Not possible to convert
$sql
to an unknow database driver:
",
$self
->
driver
,
"
no limit applied
");
$new_sql
=
$sql
;
warning
("
Not possible to convert
$sql
to an unknow database driver:
",
$self
->
driver
,
"
no limit applied
");
$new_sql
=
$sql
;
}
return
$new_sql
;
}
...
...
@@ -805,14 +820,14 @@ sub from_date_to_seconds{
my
$string
;
if
(
$self
->
driver
eq
'
mysql
'){
$string
=
"
UNIX_TIMESTAMP(
$column
)
";
$string
=
"
UNIX_TIMESTAMP(
$column
)
";
}
elsif
(
$self
->
driver
eq
'
odbc
'){
$string
=
"
DATEDIFF(second,'JAN 1 1970',
$column
)
";
$string
=
"
DATEDIFF(second,'JAN 1 1970',
$column
)
";
}
else
{
warning
("
Not possible to convert
$column
due to an unknown database driver:
",
$self
->
driver
);
return
'';
warning
("
Not possible to convert
$column
due to an unknown database driver:
",
$self
->
driver
);
return
'';
}
return
$string
;
}
...
...
@@ -837,24 +852,24 @@ sub from_seconds_to_date{
my
$string
;
if
(
$self
->
driver
eq
'
mysql
'){
if
(
$seconds
){
$string
=
"
from_unixtime(
"
.
$seconds
.
"
)
";
}
else
{
$string
=
"
\"
0000-00-00 00:00:00
\"
";
}
if
(
$seconds
){
$string
=
"
from_unixtime(
"
.
$seconds
.
"
)
";
}
else
{
$string
=
"
\"
0000-00-00 00:00:00
\"
";
}
}
elsif
(
$self
->
driver
eq
'
odbc
'){
if
(
$seconds
){
$string
=
"
DATEDIFF(date,'JAN 1 1970',
$seconds
)
";
}
else
{
$string
=
"
\"
0000-00-00 00:00:00
\"
";
}
if
(
$seconds
){
$string
=
"
DATEDIFF(date,'JAN 1 1970',
$seconds
)
";
}
else
{
$string
=
"
\"
0000-00-00 00:00:00
\"
";
}
}
else
{
warning
("
Not possible to convert
$seconds
due to an unknown database driver:
",
$self
->
driver
);
return
'';
warning
("
Not possible to convert
$seconds
due to an unknown database driver:
",
$self
->
driver
);
return
'';
}
return
$string
;
...
...
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