From ec95a8b2bf50ee0a73473e1081b947e7e36e3398 Mon Sep 17 00:00:00 2001 From: James Adams Date: Mon, 7 Dec 2020 11:04:38 +0000 Subject: [PATCH] Remove support for Oracle as a backend database This has not really been supported for a long time, nothing tests it and no sites are known to be making use of it. --- apel/db/apeldb.py | 6 --- apel/db/backends/oracle.py | 101 ------------------------------------- 2 files changed, 107 deletions(-) delete mode 100644 apel/db/backends/oracle.py diff --git a/apel/db/apeldb.py b/apel/db/apeldb.py index 7f3f7eb4c..6bb21145d 100644 --- a/apel/db/apeldb.py +++ b/apel/db/apeldb.py @@ -44,12 +44,6 @@ def __new__(cls, backend, host, port, username, pwd, db): except ImportError: logger.info('Cannot import mysql backend') - try: - from apel.db.backends.oracle import ApelOracleDb - BACKENDS['oracle'] = ApelOracleDb - except ImportError: - logger.debug('Cannot import oracle backend') - if backend not in BACKENDS.keys(): raise ApelDbException('Unknown backend: %s' % (backend)) diff --git a/apel/db/backends/oracle.py b/apel/db/backends/oracle.py deleted file mode 100644 index cdfc706bf..000000000 --- a/apel/db/backends/oracle.py +++ /dev/null @@ -1,101 +0,0 @@ -''' - Copyright (C) 2012 STFC - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -Created on 26 Jul 2012 - -@author: Alan Kyffin, STFC - -''' - -from apel.db import ApelDbException, LOGGER_ID -from apel.db.records.job import JobRecord -import cx_Oracle -import logging -# import warnings - -# Set up the logger -log = logging.getLogger(LOGGER_ID) - -# Treat cx_Oracle warnings as exceptions -# warnings.simplefilter("error", category=cx_Oracle.Warning) - - -class ApelOracleDb(object): - ''' Oracle implementation of the general ApelDb interface. ''' - - def __init__(self, host, port, username, pwd, db): - ''' Initialise variables. ''' - - self._db_connect_string = username + '/' + pwd + '@' + host + ':' + str(port) + '/' + db - self._db_log_string = username + '@' + host + ':' + str(port) + '/' + db - - self.INSERT_PROCEDURES = { - JobRecord : 'pkg_apel_dbloader.insert_temp_job_record' - } - - self.MERGE_PROCEDURES = { - JobRecord : 'pkg_apel_dbloader.merge_temp_job_records' - } - - - def test_connection(self): - ''' Tests the DB connection. ''' - - try: - con = cx_Oracle.connect(self._db_connect_string) - - log.info('Connected to: %s', self._db_log_string) - log.info('Oracle Version: %s', con.version) - - con.close() - - except Exception, e: - raise ApelDbException('Failed to connect to database: ' + str(e)) - - - def load_records(self, record_list, source): - ''' - Loads the records in the list into the DB. This is transactional - - either all or no records will be loaded. Includes the DN of the - sender. - ''' - - con = cx_Oracle.connect(self._db_connect_string) - - try: - cur = con.cursor() - - # Insert the records into temporary tables. - for record in record_list: - proc = self.INSERT_PROCEDURES[type(record)] - values = record.get_db_tuple(source) - - cur.callproc(proc, values) - - # Now merge the temporary tables into the actual tables. - for k, v in self.MERGE_PROCEDURES.iteritems(): - cur.callproc(v) - - con.commit() - con.close() - - except (cx_Oracle.Warning, cx_Oracle.Error), err: - log.error("Error loading records: %s", err) - log.error("Transaction will be rolled back.") - - con.rollback() - con.close() - - raise ApelDbException(err)