| 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::SQLite; | ||
| 31 | $Bio::EnsEMBL::DBSQL::Driver::SQLite::VERSION = '114.0.0'; | ||
| 32 | use warnings; | ||
| 33 | use strict; | ||
| 34 | |||
| 35 | use Bio::EnsEMBL::Utils::Exception qw/throw/; | ||
| 36 | |||
| 37 | use base 'Bio::EnsEMBL::DBSQL::Driver'; | ||
| 38 | |||
| 39 | sub connect_params { | ||
| 40 | my ($self, $conn) = @_; | ||
| 41 | |||
| 42 | my $dbname = $conn->dbname(); | ||
| 43 | throw "We require a dbname to connect to a SQLite database" | ||
| 44 | if !$dbname; | ||
| 45 | |||
| 46 | return { | ||
| 47 | dsn => sprintf( "DBI:SQLite:%s", $dbname ), | ||
| 48 | username => '', | ||
| 49 | password => '', | ||
| 50 | attributes => { 'RaiseError' => 1 }, | ||
| 51 | }; | ||
| 52 | } | ||
| 53 | |||
| 54 | sub from_date_to_seconds { | ||
| 55 | my ($self, $column) = @_; | ||
| 56 | return "STRFTIME('%s', $column)"; | ||
| 57 | } | ||
| 58 | |||
| 59 | sub from_seconds_to_date { | ||
| 60 | my ($self, $seconds) = @_; | ||
| 61 | return "DATETIME($seconds, 'unixepoch')"; | ||
| 62 | } | ||
| 63 | |||
| 64 | sub insert_ignore_clause { | ||
| 65 | return 'INSERT OR IGNORE'; | ||
| 66 | } | ||
| 67 | |||
| 68 | 1; |