-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
33 lines (28 loc) · 875 Bytes
/
db.py
File metadata and controls
33 lines (28 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
Class: db
Description: Basic database connectivity
Authored by: MapLarge, Inc. (Scott Rowles)
Change Log:
"""
"""
Define all the imports for the db class
"""
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
import ConfigParser
config = ConfigParser.RawConfigParser()
config.read('conf/feed_service.cfg')
db_uri = config.get('ServerConfig', 'db')
engine = create_engine(db_uri, convert_unicode=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
Base.query = db_session.query_property()
def init_db():
"""
Start the database engine connection
:return:
"""
Base.metadata.create_all(bind=engine)