| 1 | =head1 LICENSE | ||
| 2 | |||
| 3 | See the NOTICE file distributed with this work for additional information | ||
| 4 | regarding copyright ownership. | ||
| 5 | |||
| 6 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 7 | you may not use this file except in compliance with the License. | ||
| 8 | You may obtain a copy of the License at | ||
| 9 | |||
| 10 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 11 | |||
| 12 | Unless required by applicable law or agreed to in writing, software | ||
| 13 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 15 | See the License for the specific language governing permissions and | ||
| 16 | limitations under the License. | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | =head1 CONTACT | ||
| 21 | |||
| 22 | Please email comments or questions to the public Ensembl | ||
| 23 | developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. | ||
| 24 | |||
| 25 | Questions may also be sent to the Ensembl help desk at | ||
| 26 | <http://www.ensembl.org/Help/Contact>. | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | package Bio::EnsEMBL::DBSQL::Driver; | ||
| 31 | $Bio::EnsEMBL::DBSQL::Driver::VERSION = '114.0.0'; | ||
| 32 | use warnings; | ||
| 33 | use strict; | ||
| 34 | |||
| 35 | use Scalar::Util qw(weaken); | ||
| 36 | |||
| 37 | use Bio::EnsEMBL::Utils::Exception qw(throw warning); | ||
| 38 | |||
| 39 | sub new { | ||
| 40 | my ($class, $parent) = @_; | ||
| 41 | |||
| 42 | my $self = bless {}, $class; | ||
| 43 | $self->parent($parent); | ||
| 44 | |||
| 45 | return $self; | ||
| 46 | } | ||
| 47 | |||
| 48 | sub parent { | ||
| 49 | my ($self, @args) = @_; | ||
| 50 | if (@args) { | ||
| 51 | ( $self->{'_parent'} ) = @args; | ||
| 52 | weaken $self->{'_parent'}; | ||
| 53 | } | ||
| 54 | return $self->{'_parent'}; | ||
| 55 | } | ||
| 56 | |||
| 57 | sub connect_params { | ||
| 58 | my ($self, $conn) = @_; | ||
| 59 | |||
| 60 | my $dbname = $conn->dbname(); | ||
| 61 | my $dbparam = ($dbname) ? "database=${dbname};" : q{}; | ||
| 62 | |||
| 63 | my $dsn = sprintf( "DBI:%s:%shost=%s;port=%s", | ||
| 64 | $conn->driver(), $dbparam, | ||
| 65 | $conn->host(), $conn->port() ); | ||
| 66 | |||
| 67 | if ( $conn->{'disconnect_when_inactive'} ) { | ||
| 68 | $conn->{'count'}++; | ||
| 69 | if ( $conn->{'count'} > 1000 ) { | ||
| 70 | sleep 1; | ||
| 71 | $conn->{'count'} = 0; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | return { | ||
| 76 | dsn => $dsn, | ||
| 77 | username => $conn->username(), | ||
| 78 | password => $conn->password(), | ||
| 79 | attributes => { 'RaiseError' => 1 }, | ||
| 80 | }; | ||
| 81 | } | ||
| 82 | |||
| 83 | sub last_insert_id_args { | ||
| 84 | return; | ||
| 85 | } | ||
| 86 | |||
| 87 | sub can_straight_join { | ||
| 88 | return; | ||
| 89 | } | ||
| 90 | |||
| 91 | sub set_wait_timeout { | ||
| 92 | my $self = shift; | ||
| 93 | my $class = ref $self; | ||
| 94 | warning("'set_wait_timeout()' is not implemented in ${class}"); | ||
| 95 | return; | ||
| 96 | } | ||
| 97 | |||
| 98 | sub AUTOLOAD { | ||
| 99 | my ($self, @args) = @_; | ||
| 100 | my $class = ref $self; | ||
| 101 | my $method = $Bio::EnsEMBL::DBSQL::Driver::AUTOLOAD; | ||
| 102 | $method =~ s/^${class}:://; | ||
| 103 | throw("'${method}()' has not been implemented in ${class}"); | ||
| 104 | return; | ||
| 105 | } | ||
| 106 | |||
| 107 | sub DESTROY { } # prevent DESTROY being handled by AUTOLOAD | ||
| 108 | |||
| 109 | 1; |