本文整理汇总了Python中tools.dbmaint.psql函数的典型用法代码示例。如果您正苦于以下问题:Python psql函数的具体用法?Python psql怎么用?Python psql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了psql函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_psql_with_ignored_dry_run_flag
def test_psql_with_ignored_dry_run_flag(self):
"""
Calls the psql command if the `dryrun` flag is set in the configuration
but the 'ignore_dryrun' parameter is set to `True`.
"""
def fake_runner(cmds):
"""Fake command runner function to be used in this test."""
fake_runner.number_of_calls += 1
fake_runner.number_of_calls = 0
config = {
"dryrun": True,
"path": "/tmp",
"host": "localhost",
"db": "openquake",
"user": "postgres"
}
psql(
config,
cmd="SELECT * from admin.revision_info",
ignore_dryrun=True,
runner=fake_runner)
self.assertEqual(1, fake_runner.number_of_calls)
开发者ID:ROB-Seismology,项目名称:oq-engine,代码行数:25,代码来源:tools_dbmaint_test.py
示例2: test_psql_with_neither_script_nor_command
def test_psql_with_neither_script_nor_command(self):
"""
Raises an `Exception` if neither a command nor a script are passed.
"""
config = {"dryrun": True, "path": "/tmp", "host": "localhost",
"db": "openquake", "user": "postgres"}
try:
psql(config)
except Exception, e:
self.assertEqual(
"Neither SQL script nor command specified.", e.args[0])
开发者ID:Chunghan,项目名称:oq-engine,代码行数:11,代码来源:tools_dbmaint_test.py
示例3: test_psql_with_both_script_and_command
def test_psql_with_both_script_and_command(self):
"""
Raises an `Exception` if both a command and a script are passed.
"""
config = {"dryrun": True, "path": "/tmp", "host": "localhost",
"db": "openquake", "user": "postgres"}
try:
psql(config, cmd="SELECT * from admin.revision_info", script="xxx")
except Exception, e:
self.assertEqual(
"Please specify either an SQL script or a command.", e.args[0])
开发者ID:Chunghan,项目名称:oq-engine,代码行数:11,代码来源:tools_dbmaint_test.py
示例4: test_psql_cmd_with_script
def test_psql_cmd_with_script(self):
"""Tests the psql command params with an SQL script file."""
def fake_runner(cmds):
"""Fake command runner function to be used in this test."""
fake_runner.args = cmds
fake_runner.args = []
config = {"dryrun": False, "path": "/tmp", "host": "localhost",
"db": "0penquark", "user": "postgres"}
psql(config, script="xxx", runner=fake_runner)
self.assertEqual(
["psql", "-d", "0penquark", "-U", "postgres", "-f", "/tmp/xxx"],
fake_runner.args)
开发者ID:danciul,项目名称:openquake,代码行数:13,代码来源:tools_dbmaint_unittest.py
示例5: test_psql_cmd_with_command
def test_psql_cmd_with_command(self):
"""Tests the psql command params with an SQL command."""
def fake_runner(cmds):
"""Fake command runner function to be used in this test."""
fake_runner.args = cmds
fake_runner.args = []
config = {"dryrun": False, "path": "/tmp", "host": "localhost",
"db": "openquake", "user": "chuckn"}
psql(config, cmd="SELECT * from admin.revision_info",
runner=fake_runner)
self.assertEqual(
["psql", "-d", "openquake", "-U", "chuckn", "-c",
"SELECT * from admin.revision_info"], fake_runner.args)
开发者ID:danciul,项目名称:openquake,代码行数:14,代码来源:tools_dbmaint_unittest.py
示例6: test_psql_with_dry_run_flag
def test_psql_with_dry_run_flag(self):
"""
Does not call the psql command if the `dryrun` flag is set in
the configuration.
"""
def fake_runner(cmds):
"""Fake command runner function to be used in this test."""
fake_runner.number_of_calls += 1
fake_runner.number_of_calls = 0
config = {"dryrun": True, "path": "/tmp", "host": "localhost",
"db": "openquake", "user": "postgres"}
psql(config, cmd="SELECT * from admin.revision_info",
runner=fake_runner)
self.assertEqual(0, fake_runner.number_of_calls)
开发者ID:Chunghan,项目名称:oq-engine,代码行数:15,代码来源:tools_dbmaint_test.py
示例7: test_psql_with_local_host_ip
def test_psql_with_local_host_ip(self):
"""
Does not specify the `-h` flag in the `psql` command when the host in
the configuration is `127.0.0.1`.
"""
def fake_runner(cmds):
"""Fake command runner function to be used in this test."""
fake_runner.args = cmds
fake_runner.args = []
config = {"dryrun": False, "path": "/tmp", "host": "127.0.0.1",
"db": "openquake", "user": "postgres"}
psql(config, cmd="SELECT * from admin.revision_info",
runner=fake_runner)
self.assertTrue("-h" not in fake_runner.args)
开发者ID:Chunghan,项目名称:oq-engine,代码行数:15,代码来源:tools_dbmaint_test.py
示例8: test_psql_with_non_local_host
def test_psql_with_non_local_host(self):
"""
The `-h` flag *is* specified in the `psql` command when the host in
the configuration is not `localhost`.
"""
def fake_runner(cmds):
"""Fake command runner function to be used in this test."""
fake_runner.args = cmds
fake_runner.args = []
config = {"dryrun": False, "path": "/tmp", "host": "gozilla",
"db": "openquake", "user": "postgres"}
psql(config, cmd="SELECT * from admin.revision_info",
runner=fake_runner)
self.assertTrue("-h" in fake_runner.args)
开发者ID:Chunghan,项目名称:oq-engine,代码行数:15,代码来源:tools_dbmaint_test.py
注:本文中的tools.dbmaint.psql函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论