本文整理汇总了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
示例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
)
示例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()
示例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)