Merge "Switch from BashFeature to Feature of bgpvpn testcase"
[functest.git] / functest / api / database / db.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9
10 """
11 Create database to store task results using sqlalchemy
12 """
13
14 from sqlalchemy import create_engine
15 from sqlalchemy.ext.declarative import declarative_base
16 from sqlalchemy.orm import scoped_session, sessionmaker
17
18
19 SQLITE = 'sqlite:////tmp/functest.db'
20
21 ENGINE = create_engine(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()