Merge "Add vBNG test cases stats processing functionality"
[yardstick.git] / api / database / __init__.py
1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from __future__ import absolute_import
10 import logging
11
12 from sqlalchemy import create_engine
13 from sqlalchemy.orm import scoped_session, sessionmaker
14 from sqlalchemy.ext.declarative import declarative_base
15
16 from yardstick.common import constants as consts
17
18 logger = logging.getLogger(__name__)
19 logger.setLevel(logging.DEBUG)
20
21 engine = create_engine(consts.SQLITE, convert_unicode=True)
22 db_session = scoped_session(sessionmaker(autocommit=False,
23                                          autoflush=False,
24                                          bind=engine))
25 Base = declarative_base()
26 Base.query = db_session.query_property()