本文整理汇总了Python中mpp.lib.PSQL.PSQL.database_exists方法的典型用法代码示例。如果您正苦于以下问题:Python PSQL.database_exists方法的具体用法?Python PSQL.database_exists怎么用?Python PSQL.database_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpp.lib.PSQL.PSQL
的用法示例。
在下文中一共展示了PSQL.database_exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reset_database_not_exists
# 需要导入模块: from mpp.lib.PSQL import PSQL [as 别名]
# 或者: from mpp.lib.PSQL.PSQL import database_exists [as 别名]
def test_reset_database_not_exists(self):
dbname = 'testresetdb'
PSQL.reset_database(dbname)
time.sleep(4)
self.assertTrue(PSQL.database_exists(dbname))
PSQL.drop_database(dbname)
time.sleep(4)
self.assertFalse(PSQL.database_exists(dbname))
示例2: test_create_database
# 需要导入模块: from mpp.lib.PSQL import PSQL [as 别名]
# 或者: from mpp.lib.PSQL.PSQL import database_exists [as 别名]
def test_create_database(self):
dbname = 'testdb'
self.assertFalse(PSQL.database_exists(dbname))
PSQL.create_database(dbname)
time.sleep(4)
self.assertTrue(PSQL.database_exists(dbname))
PSQL.drop_database(dbname)
time.sleep(4)
self.assertFalse(PSQL.database_exists(dbname))
示例3: test_drop_database
# 需要导入模块: from mpp.lib.PSQL import PSQL [as 别名]
# 或者: from mpp.lib.PSQL.PSQL import database_exists [as 别名]
def test_drop_database(self):
dbname = "testdropdb"
self.assertFalse(PSQL.database_exists(dbname))
PSQL.create_database(dbname)
time.sleep(4)
self.assertTrue(PSQL.database_exists(dbname))
# dropdb
PSQL.drop_database(dbname)
time.sleep(4)
self.assertFalse(PSQL.database_exists(dbname))
示例4: test_create_database_already_exists
# 需要导入模块: from mpp.lib.PSQL import PSQL [as 别名]
# 或者: from mpp.lib.PSQL.PSQL import database_exists [as 别名]
def test_create_database_already_exists(self):
dbname = 'testdupdb'
self.assertFalse(PSQL.database_exists(dbname))
PSQL.create_database(dbname)
time.sleep(4)
self.assertTrue(PSQL.database_exists(dbname))
with self.assertRaises(PSQLException) as cm:
PSQL.create_database(dbname)
PSQL.drop_database(dbname)
time.sleep(4)
self.assertFalse(PSQL.database_exists(dbname))
示例5: setUpClass
# 需要导入模块: from mpp.lib.PSQL import PSQL [as 别名]
# 或者: from mpp.lib.PSQL.PSQL import database_exists [as 别名]
def setUpClass(cls):
dbs = ['testdb', 'testdupdb', 'testdropdb', 'testresetdb', 'testresetdb2']
for db in dbs:
if PSQL.database_exists(db):
PSQL.drop_database(db)
curr_dir = os.path.dirname(inspect.getfile(cls))
for filename in os.listdir(curr_dir):
if fnmatch.fnmatch(filename, "*.out"):
os.remove(os.path.join(curr_dir, filename))
示例6: test_reset_database_exists
# 需要导入模块: from mpp.lib.PSQL import PSQL [as 别名]
# 或者: from mpp.lib.PSQL.PSQL import database_exists [as 别名]
def test_reset_database_exists(self):
dbname = 'testresetdb2'
PSQL.create_database(dbname)
time.sleep(4)
PSQL.run_sql_command(sql_cmd = "CREATE TABLE testresettable(i int)", dbname = dbname)
output = PSQL.run_sql_command(sql_cmd = "SELECT * FROM testresettable", dbname = dbname)
self.assertIsNotNone(re.search('0 rows', output))
PSQL.reset_database(dbname)
out_file = os.path.join(os.path.dirname(inspect.getfile(self.__class__)),'test_reset_database_exists.out')
self.assertFalse(os.path.exists(out_file))
PSQL.run_sql_command(sql_cmd = "SELECT * FROM testresettable", dbname = dbname, out_file = out_file)
self.assertTrue(os.path.exists(out_file))
# stdout should be none
with open(out_file, 'r') as f:
output = f.read()
self.assertIsNotNone(re.search('relation.*does not exist', output))
os.remove(out_file)
self.assertFalse(os.path.exists(out_file))
PSQL.drop_database(dbname)
time.sleep(4)
self.assertFalse(PSQL.database_exists(dbname))