本文整理汇总了Python中config.Configuration.database_url方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.database_url方法的具体用法?Python Configuration.database_url怎么用?Python Configuration.database_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.Configuration
的用法示例。
在下文中一共展示了Configuration.database_url方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initialize_database
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import database_url [as 别名]
def initialize_database(autoinitialize=True):
testing = 'TESTING' in os.environ
db_url = Configuration.database_url()
if autoinitialize:
SessionManager.initialize(db_url)
session_factory = SessionManager.sessionmaker(db_url)
_db = flask_scoped_session(session_factory, app)
app._db = _db
log_level = LogConfiguration.initialize(_db, testing=testing)
debug = log_level == 'DEBUG'
app.config['DEBUG'] = debug
app.debug = debug
_db.commit()
logging.getLogger().info("Application debug mode==%r" % app.debug)
示例2: import
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import database_url [as 别名]
from flask import (
Flask,
Response,
redirect,
)
from flask_sqlalchemy_session import flask_scoped_session
from sqlalchemy.orm import sessionmaker
from config import Configuration
from core.model import SessionManager
from core.util import LanguageCodes
from flask.ext.babel import Babel
app = Flask(__name__)
testing = 'TESTING' in os.environ
db_url = Configuration.database_url(testing)
SessionManager.initialize(db_url)
session_factory = SessionManager.sessionmaker(db_url)
_db = flask_scoped_session(session_factory, app)
SessionManager.initialize_data(_db)
app.config['BABEL_DEFAULT_LOCALE'] = LanguageCodes.three_to_two[Configuration.localization_languages()[0]]
app.config['BABEL_TRANSLATION_DIRECTORIES'] = "../translations"
babel = Babel(app)
import routes
if Configuration.get(Configuration.INCLUDE_ADMIN_INTERFACE):
import admin.routes
debug = Configuration.logging_policy().get("level") == 'DEBUG'
logging.getLogger().info("Application debug mode==%r" % debug)
示例3: get_database_connection
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import database_url [as 别名]
def get_database_connection(cls):
url = Configuration.database_url()
engine, connection = SessionManager.initialize(url)
return engine, connection