| 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 | # FIXME: should this be ::ODBC rather than ::odbc ?? | ||
| 31 | |||
| 32 | package Bio::EnsEMBL::DBSQL::Driver::odbc; | ||
| 33 | $Bio::EnsEMBL::DBSQL::Driver::odbc::VERSION = '114.0.0'; | ||
| 34 | use warnings; | ||
| 35 | use strict; | ||
| 36 | |||
| 37 | use Bio::EnsEMBL::Utils::Exception qw(warning); | ||
| 38 | |||
| 39 | use base 'Bio::EnsEMBL::DBSQL::Driver'; | ||
| 40 | |||
| 41 | sub new { | ||
| 42 | my ($self, @args) = @_; | ||
| 43 | warning(__PACKAGE__ . ' is untested and is being used only to collect odbc-specific code'); | ||
| 44 | return $self->SUPER::new(@args); | ||
| 45 | } | ||
| 46 | |||
| 47 | sub connect_params { | ||
| 48 | my ($self, $conn) = @_; | ||
| 49 | |||
| 50 | my $dsn = sprintf( "DBI:ODBC:%s", $conn->dbname() ); | ||
| 51 | |||
| 52 | return { | ||
| 53 | dsn => $dsn, | ||
| 54 | username => $conn->username(), | ||
| 55 | password => $conn->password(), | ||
| 56 | attributes => { | ||
| 57 | 'LongTruncOk' => 1, | ||
| 58 | 'LongReadLen' => 2**16 - 8, | ||
| 59 | 'RaiseError' => 1, | ||
| 60 | 'PrintError' => 0, | ||
| 61 | 'odbc_cursortype' => 2, | ||
| 62 | }, | ||
| 63 | }; | ||
| 64 | } | ||
| 65 | |||
| 66 | sub from_date_to_seconds { | ||
| 67 | my ($self, $column) = @_; | ||
| 68 | return "DATEDIFF(second,'JAN 1 1970',$column)"; | ||
| 69 | } | ||
| 70 | |||
| 71 | sub from_seconds_to_date { | ||
| 72 | my ($self, $seconds) = @_; | ||
| 73 | return "DATEDIFF(date,'JAN 1 1970',$seconds)"; | ||
| 74 | } | ||
| 75 | |||
| 76 | 1; |