本文整理汇总了Python中mysqlapi.api.models.DatabaseManager.drop_user方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseManager.drop_user方法的具体用法?Python DatabaseManager.drop_user怎么用?Python DatabaseManager.drop_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqlapi.api.models.DatabaseManager
的用法示例。
在下文中一共展示了DatabaseManager.drop_user方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_user_in_shared_instance_with_public_host
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def test_create_user_in_shared_instance_with_public_host(self):
settings.SHARED_SERVER = "localhost"
settings.SHARED_SERVER_PUBLIC_HOST = "10.10.10.10"
instance = Instance.objects.create(
name="inside_out",
shared=True,
state="running",
)
try:
request = RequestFactory().post("/", {"unit-host": "192.168.1.10"})
response = CreateUser.as_view()(request, "inside_out")
self.assertEqual(201, response.status_code)
content = json.loads(response.content)
expected = {
u"MYSQL_HOST": u"10.10.10.10",
u"MYSQL_PORT": u"3306",
u"MYSQL_DATABASE_NAME": "inside_out",
u"MYSQL_USER": u"inside_out",
u"MYSQL_PASSWORD": content["MYSQL_PASSWORD"],
}
self.assertEqual(expected, content)
sql = "select User, Host FROM mysql.user " +\
"WHERE User='inside_out' AND Host='%'"
self.cursor.execute(sql)
row = self.cursor.fetchone()
self.assertIsNotNone(row)
finally:
db = DatabaseManager("inside_out")
db.drop_user("inside_out", "%")
instance.delete()
示例2: test_create_user
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def test_create_user(self):
instance = Instance.objects.create(
name="ciclops",
host="127.0.0.1",
ec2_id="i-009",
state="running",
)
try:
request = RequestFactory().post("/", {"unit-host": "192.168.1.1"})
response = CreateUser.as_view()(request, "ciclops")
self.assertEqual(201, response.status_code)
content = json.loads(response.content)
expected = {
u"MYSQL_HOST": u"127.0.0.1",
u"MYSQL_PORT": u"3306",
u"MYSQL_DATABASE_NAME": "ciclops",
u"MYSQL_USER": u"ciclops",
u"MYSQL_PASSWORD": content["MYSQL_PASSWORD"],
}
self.assertDictEqual(expected, content)
sql = "select User, Host FROM mysql.user " +\
"WHERE User='ciclops' AND Host='%'"
self.cursor.execute(sql)
row = self.cursor.fetchone()
self.assertEqual("ciclops", row[0])
finally:
db = DatabaseManager("ciclops")
db.drop_user("ciclops", "%")
instance.delete()
示例3: test_create_user_in_a_custom_service_host
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def test_create_user_in_a_custom_service_host(self):
instance = Instance.objects.create(
name="ciclops",
host="127.0.0.1",
ec2_id="i-009",
state="running",
)
try:
request = RequestFactory().post("/", {"hostname": "192.168.1.1", "service_host": "127.0.0.1"})
response = CreateUser.as_view()(request, "ciclops")
self.assertEqual(201, response.status_code)
content = json.loads(response.content)
expected = {
u"MYSQL_USER": u"ciclops",
u"MYSQL_PASSWORD": content["MYSQL_PASSWORD"],
}
self.assertDictEqual(expected, content)
self.cursor.execute("select User, Host FROM mysql.user WHERE User='ciclops' AND Host='192.168.1.1'")
row = self.cursor.fetchone()
self.assertEqual("ciclops", row[0])
self.assertEqual("192.168.1.1", row[1])
finally:
db = DatabaseManager("ciclops")
db.drop_user("ciclops", "192.168.1.1")
instance.delete()
示例4: drop_user
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def drop_user(request, name, hostname):
host = _get_service_host(request.GET)
db = DatabaseManager(name, host)
try:
db.drop_user(name, hostname)
except Exception, e:
return HttpResponse(e[1], status=500)
示例5: test_drop_user
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def test_drop_user(self):
db = DatabaseManager("magneto")
db.create_user("magneto", "localhost")
db.drop_user("magneto", "localhost")
self.cursor.execute("select User, Host FROM mysql.user WHERE User='wolverine' AND Host='localhost'")
row = self.cursor.fetchone()
self.assertFalse(row)
示例6: test_create_user_should_generate_an_username_when_username_length_is_greater_than_16
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def test_create_user_should_generate_an_username_when_username_length_is_greater_than_16(self):
db = DatabaseManager("usernamegreaterthan16")
username, password = db.create_user("usernamegreaterthan16", "localhost")
self.cursor.execute("select User, Host FROM mysql.user WHERE User like 'usernamegrea%' AND Host='localhost'")
row = self.cursor.fetchone()
self.assertEqual("usernamegrea", row[0][:12])
db = DatabaseManager(row[0])
db.drop_user(username, "localhost")
示例7: test_create_user
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def test_create_user(self):
db = DatabaseManager("wolverine")
db.create_user("wolverine", "localhost")
self.cursor.execute("select User, Host FROM mysql.user WHERE User='wolverine' AND Host='localhost'")
row = self.cursor.fetchone()
self.assertEqual("wolverine", row[0])
self.assertEqual("localhost", row[1])
db.drop_user("wolverine", "localhost")
示例8: test_create__and_drop_user_username_greater_than_16_chars
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def test_create__and_drop_user_username_greater_than_16_chars(self):
db = DatabaseManager("anusernamegreaterthan16")
db.create_user("anusernamegreaterthan16", "%")
db.drop_user("anusernamegreaterthan16", "%")
sql = "select User, Host FROM mysql.user " + \
"WHERE User LIKE 'anusernamegr%' AND Host='%'"
self.cursor.execute(sql)
row = self.cursor.fetchone()
self.assertFalse(row)
示例9: test_drop_user
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def test_drop_user(self):
db = DatabaseManager("magneto")
db.create_user("magneto", "%")
db.drop_user("magneto", "%")
sql = "select User, Host FROM mysql.user " +\
"WHERE User='wolverine' AND Host='%'"
self.cursor.execute(sql)
row = self.cursor.fetchone()
self.assertFalse(row)
示例10: test_create_user_generates_username_for_dbs_grater_than_16_chars
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def test_create_user_generates_username_for_dbs_grater_than_16_chars(self):
db = DatabaseManager("usernamegreaterthan16")
username, password = db.create_user("usernamegreaterthan16", "%")
sql = "select User, Host FROM mysql.user " +\
"WHERE User like 'usernamegrea%' AND Host='%'"
self.cursor.execute(sql)
row = self.cursor.fetchone()
self.assertEqual("usernamegrea", row[0][:12])
db = DatabaseManager(row[0])
db.drop_user(username, "%")
示例11: test_create_user
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def test_create_user(self):
db = DatabaseManager("wolverine")
db.create_user("wolverine", "%")
sql = "select User, Host FROM mysql.user " +\
"WHERE User='wolverine' AND Host='%'"
self.cursor.execute(sql)
row = self.cursor.fetchone()
self.assertEqual("wolverine", row[0])
self.assertEqual("%", row[1])
db.drop_user("wolverine", "%")
示例12: test_export
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def test_export(self):
db = DatabaseManager("magneto")
db.create_database()
db.create_user("magneto", "localhost")
self.cursor.execute("create table magneto.foo ( test varchar(255) );")
expected = """/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `foo` (
`test` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
"""
result = db.export()
self.assertEqual(expected, result.replace("InnoDB", "MyISAM"))
db.drop_database()
db.drop_user("magneto", "localhost")
示例13: test_export_from_a_custom_service_host
# 需要导入模块: from mysqlapi.api.models import DatabaseManager [as 别名]
# 或者: from mysqlapi.api.models.DatabaseManager import drop_user [as 别名]
def test_export_from_a_custom_service_host(self):
db = DatabaseManager("magneto", host="127.0.0.1")
db.create_database()
db.create_user("magneto", "localhost")
self.cursor.execute("create table magneto.foo ( test varchar(255) );")
expected = """/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `foo` (
`test` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
"""
request = RequestFactory().get("/", {"service_host": "127.0.0.1"})
result = export(request, "magneto")
self.assertEqual(200, result.status_code)
self.assertEqual(expected, result.content.replace("InnoDB", "MyISAM"))
db.drop_database()
db.drop_user("magneto", "localhost")