Skip to content

Commit

Permalink
Added db support
Browse files Browse the repository at this point in the history
  • Loading branch information
DoRTaL94 committed Apr 25, 2020
1 parent 7ba1ebc commit 934df87
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions edison/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from edison.config import get_config_object


# Put app here so the entire app could import it.
app = Flask(__name__)
app.config.from_object(get_config_object(app.config["ENV"]))
basedir = os.path.abspath(os.path.dirname(__file__))
db = SQLAlchemy(app)
6 changes: 6 additions & 0 deletions edison/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
# API description in swagger - https://app.swaggerhub.com/apis/DoRTaL94/UserManagment/1.0.0

app = edison.app
db = edison.db

# Creates all tables defined in the database models and the only ones that are not created yet.
# If there's any change in the database models you should perform a migration to apply this change in the database itself.
# More about database migrations can be found in /edison/migrations/README.
db.create_all()

@app.route("/")
def index():
Expand Down
4 changes: 4 additions & 0 deletions edison/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def get_config_object(env_keyword: str):
class Config:
ENV_KEYWORD = ""
DEBUG = False
# Turns off the Flask-SQLAlchemy event system
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_DATABASE_URI = 'postgresql://postgres:[email protected]/edison'

# PostgreSQL connection string should be updated once an actual production environment is established.
class ProductionConfig(Config):
ENV_KEYWORD = "production"

Expand Down

0 comments on commit 934df87

Please sign in to comment.