1
# -*- coding: utf-8 -*-
2
# swtstore->dbsetup.py
3
4
# Create and setup databases for the first time run of the application
5
6
import sys, os
7
8
# Get the path to the base directory of the app
9
BASE_DIR = os.path.join(os.path.dirname(__file__))
10
11
# append the path to the WSGI env path
12
sys.path.insert(0, BASE_DIR)
13
14
# Import and create the app; also get the db instance from the current app
15
from swtstore import create_app, getDBInstance
16
17
app = create_app()
18
19
db = getDBInstance()
20
21
# Import all modules which represents a SQLAlchemy model;
22
# they have corresponding tables that are needed to be created
23
from swtstore.classes.models import Sweet, Context, Client
24
from swtstore.classes.models.um import User, Group, Membership
25
26
27
if __name__ == '__main__':
28
    # Create them!
29
    db.create_all()