This file looks large and may slow your browser down if we attempt
to syntax highlight it, so we are showing it without any
pretty colors.
Highlight
it anyway.
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 |
7 |
import os |
8 |
|
9 |
# Get the path to the base directory of the app |
10 |
BASE_DIR = os.path.join(os.path.dirname(__file__)) |
11 |
|
12 |
# append the path to the WSGI env path |
13 |
sys.path.insert(0, BASE_DIR) |
14 |
|
15 |
# Import and create the app; also get the db instance from the current app |
16 |
from swtstore import create_app, getDBInstance |
17 |
|
18 |
app = create_app() |
19 |
|
20 |
db = getDBInstance() |
21 |
|
22 |
# Import all modules which represents a SQLAlchemy model; |
23 |
# they have corresponding tables that are needed to be created |
24 |
from swtstore.classes.models import Sweet, Context, Client |
25 |
from swtstore.classes.models import User, Group, Membership |
26 |
|
27 |
|
28 |
if __name__ == '__main__': |
29 |
# Create them! |
30 |
db.create_all() |