当前位置: 首页>>代码示例>>Python>>正文


Python postgres_ext.PostgresqlExtDatabase方法代码示例

本文整理汇总了Python中playhouse.postgres_ext.PostgresqlExtDatabase方法的典型用法代码示例。如果您正苦于以下问题:Python postgres_ext.PostgresqlExtDatabase方法的具体用法?Python postgres_ext.PostgresqlExtDatabase怎么用?Python postgres_ext.PostgresqlExtDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在playhouse.postgres_ext的用法示例。


在下文中一共展示了postgres_ext.PostgresqlExtDatabase方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_db

# 需要导入模块: from playhouse import postgres_ext [as 别名]
# 或者: from playhouse.postgres_ext import PostgresqlExtDatabase [as 别名]
def get_db():
    db = None

    if env == 'test':
        db = PostgresqlExtDatabase(
            TEST_DB_NAME,
            user=DB_UN,
            password=DB_PW,
            host=DB_HOST,
            port=DB_PORT)
    else:
        db = PostgresqlExtDatabase(
            DB_NAME,
            user=DB_UN,
            password=DB_PW,
            host=DB_HOST,
            port=DB_PORT)

    return db 
开发者ID:vilmibm,项目名称:tildemush,代码行数:21,代码来源:config.py

示例2: get_db

# 需要导入模块: from playhouse import postgres_ext [as 别名]
# 或者: from playhouse.postgres_ext import PostgresqlExtDatabase [as 别名]
def get_db(self, name='default'):

        """
        Get a Postgres database object.

        Args:
            name (str): The database key.

        Returns:
            The database object.
        """

        defaults = self['postgres']['default']['args']

        db = (
            self['postgres']
            .get(name, {})
            .get('args', {})
        )

        args = dict(
            list(defaults.items()) +
            list(db.items())
        )

        return PostgresqlExtDatabase(
            autorollback=True,
            register_hstore=False,
            **args
        ) 
开发者ID:davidmcclure,项目名称:open-syllabus-project,代码行数:32,代码来源:config.py

示例3: setUp

# 需要导入模块: from playhouse import postgres_ext [as 别名]
# 或者: from playhouse.postgres_ext import PostgresqlExtDatabase [as 别名]
def setUp(self):
    os.system("createdb peeweedbevolve_test && psql peeweedbevolve_test -c 'create extension IF NOT EXISTS hstore;' > /dev/null 2> /dev/null")
    self.db = pwe.PostgresqlExtDatabase('peeweedbevolve_test')
    self.db.connect()
    peeweedbevolve.clear() 
开发者ID:keredson,项目名称:peewee-db-evolve,代码行数:7,代码来源:test.py

示例4: get_cfg

# 需要导入模块: from playhouse import postgres_ext [as 别名]
# 或者: from playhouse.postgres_ext import PostgresqlExtDatabase [as 别名]
def get_cfg():
    '''
    Get the configure value.
    '''

    cfg_var = dir(cfg)

    if 'DB_CFG' in cfg_var:
        db_cfg = cfg.DB_CFG
    else:
        db_cfg = ConfigDefault.DB_CFG

    if 'SMTP_CFG' in cfg_var:
        smtp_cfg = cfg.SMTP_CFG
    else:
        smtp_cfg = ConfigDefault.SMTP_CFG

    if 'SITE_CFG' in cfg_var:
        site_cfg = cfg.SITE_CFG
    else:
        site_cfg = ConfigDefault.SITE_CFG

    if 'ROLE_CFG' in cfg_var:
        role_cfg = cfg.ROLE_CFG
    else:
        role_cfg = ConfigDefault.ROLE_CFG

    role_cfg['view'] = role_cfg.get('view', '')
    role_cfg['add'] = role_cfg.get('add', '1000')
    role_cfg['edit'] = role_cfg.get('edit', '2000')
    role_cfg['delete'] = role_cfg.get('delete', '3000')
    role_cfg['admin'] = role_cfg.get('admin', '0300')

    ###################################################################

    site_url = site_cfg['site_url'].strip('/')
    site_cfg['site_url'] = site_url
    infor = site_url.split(':')
    if len(infor) == 1:
        site_cfg['PORT'] = 8888
    else:
        site_cfg['PORT'] = infor[-1]

    if 'DEBUG' in site_cfg:
        pass
    else:
        site_cfg['DEBUG'] = False

    db_con = PostgresqlExtDatabase(
        db_cfg['db'],
        user=db_cfg.get('user', db_cfg['db']),
        password=db_cfg['pass'],
        host=db_cfg.get('host', '127.0.0.1'),
        port=db_cfg.get('port', '5432'),
        autocommit=True,
        autorollback=True)

    return (db_con, smtp_cfg, site_cfg, role_cfg) 
开发者ID:bukun,项目名称:TorCMS,代码行数:60,代码来源:tools.py


注:本文中的playhouse.postgres_ext.PostgresqlExtDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。