Python settings 模块,DATABASE 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用settings.DATABASE

项目:caoliuscrapy    作者:leyle    | 项目源码 | 文件源码
def __init__(self):
        handlers = [
            URLSpec(r'/', IndexHandler),
            URLSpec(r'/cat/(\d{1,2})', CatHandler, name="cat"),
            URLSpec(r'/detail/(\w+)', DetailHandler),
            URLSpec(r'/login', LoginHandler),
        ]

        tornado.web.Application.__init__(self, handlers, **settings.settings)
        self.db = torndb.Connection(host=settings.DBHOST, database=settings.DATABASE, user=settings.DBUSER, password=settings.DBPWD)
项目:housebot    作者:jbkopecky    | 项目源码 | 文件源码
def initialize(self):
        print("Connecting to %s ..." % self.db)
        self.con = sqlite3.connect(DATABASE)
项目:aiohttp-login    作者:imbolc    | 项目源码 | 文件源码
def create_app(loop):
    app = web.Application(loop=loop, debug=settings.DEBUG)
    setup_jinja(app, settings.DEBUG)
    aiohttp_session.setup(app, EncryptedCookieStorage(
        settings.SESSION_SECRET.encode('utf-8'),
        max_age=settings.SESSION_MAX_AGE))
    app.middlewares.append(aiohttp_login.flash.middleware)

    app.router.add_get('/', handlers.index)
    app.router.add_get('/users/', handlers.users, name='users')

    app['db'] = await asyncpg.create_pool(dsn=settings.DATABASE, loop=loop)
    aiohttp_login.setup(app, AsyncpgStorage(app['db']), settings.AUTH)

    return app
项目:Web-Scraping    作者:Martian2Lee    | 项目源码 | 文件源码
def db_connect():
    return create_engine(URL(**settings.DATABASE))
项目:modify-api    作者:li-kai    | 项目源码 | 文件源码
def __init__(self):
        """
        Initializes database connection.
        """
        try:
            self.connection = psycopg2.connect(
                database=DATABASE['database'],
                user=DATABASE['username'],
                password=DATABASE['password'],
                host=DATABASE['host']
            )
            self.cursor = self.connection.cursor()
        except Exception, e:
            raise e
项目:rhyme    作者:zx576    | 项目源码 | 文件源码
def build(self):

        existed = os.path.exists(DATABASE)

        if not existed:
            db.connect()
            db.create_tables(self.tables)