Skip to content

Commit

Permalink
Added SQLAlchemy echo to dev config
Browse files Browse the repository at this point in the history
Moved logging init to app init
  • Loading branch information
n.lyubchich committed Aug 25, 2015
1 parent 7b3b443 commit 3512b52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os
import logging
import logging.config
import production_settings

BASEDIR = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -131,13 +129,12 @@ class DevelopmentConfig(Config):
DEBUG = True
DEVELOPMENT = True

SQLALCHEMY_ECHO = True

# Database
SQLALCHEMY_DATABASE_URI = 'postgresql://root:qwerty@localhost/hrportal'


class TestingConfig(Config):
TESTING = True
SQLALCHEMY_DATABASE_URI = 'sqlite://'


logging.config.dictConfig(Config.LOG_CONFIG)
4 changes: 2 additions & 2 deletions project/application.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from importlib import import_module
import logging
import logging.config
from os import environ
from flask import Flask
from project.lib.filters import datetime
Expand All @@ -13,8 +14,6 @@ def create_app():
app = Flask(__name__, static_url_path='/static')
used_config = environ.get('APP_SETTINGS', 'config.ProductionConfig')
app.config.from_object(used_config)
if (used_config == 'config.DevelopmentConfig'):
logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)

with app.app_context():
for module in app.config.get('DB_MODELS_IMPORT', list()):
Expand All @@ -24,6 +23,7 @@ def create_app():
import_module(bp.import_name)
app.register_blueprint(bp)

logging.config.dictConfig(app.config["LOG_CONFIG"])
db.init_app(app)
mail.init_app(app)
celery.init_app(app)
Expand Down

0 comments on commit 3512b52

Please sign in to comment.