1 # ================================================================================
2 # Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
3 # ================================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # ============LICENSE_END=========================================================
18 Base class for APIs to interact with application database using sqlAlchemy ORM lib and postgresSql driver
21 from sqlalchemy.orm import sessionmaker
22 from ..db_dao import DaoBase
24 from psycopg2.extras import execute_values
29 class DbAccess(object):
30 logger = logging.getLogger("dti_handler.DbAccess")
35 self.engine = DaoBase.getDbEngine()
36 # create a configured "Session" class
37 Session = sessionmaker(bind=self.engine)
40 self.session = Session()
42 def saveDomainObject(self, obj):
47 def deleteDomainObject(self,obj):
48 self.session.delete(obj)