本文整理汇总了Python中arango.Arango.database方法的典型用法代码示例。如果您正苦于以下问题:Python Arango.database方法的具体用法?Python Arango.database怎么用?Python Arango.database使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arango.Arango
的用法示例。
在下文中一共展示了Arango.database方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DatabaseManagementTest
# 需要导入模块: from arango import Arango [as 别名]
# 或者: from arango.Arango import database [as 别名]
class DatabaseManagementTest(unittest.TestCase):
"""Tests for managing ArangoDB databases."""
def setUp(self):
self.arango = Arango()
self.db_name = get_next_db_name(self.arango)
# Test database cleaup
self.addCleanup(self.arango.delete_database,
name=self.db_name, safe_delete=True)
def test_database_create_and_delete(self):
self.arango.create_database(self.db_name)
self.assertIn(self.db_name, self.arango.databases["all"])
# Check the properties of the new database
self.assertEqual(self.arango.database(self.db_name).name,
self.db_name)
self.assertEqual(self.arango.database(self.db_name).is_system, False)
# Delete the test database
self.arango.delete_database(self.db_name)
self.assertNotIn(self.db_name, self.arango.databases["all"])
def test_database_properties(self):
db = self.arango.database("_system")
self.assertEqual(db.name, "_system")
self.assertTrue(isinstance(db.properties, dict))
self.assertTrue(is_string(db.id))
self.assertTrue(is_string(db.path))
self.assertEqual(db.is_system, True)
示例2: DatabaseManagementTest
# 需要导入模块: from arango import Arango [as 别名]
# 或者: from arango.Arango import database [as 别名]
class DatabaseManagementTest(unittest.TestCase):
def setUp(self):
self.arango = Arango()
def test_database_add_and_remove(self):
db_name = get_next_db_name(self.arango)
self.arango.add_database(db_name)
self.assertIn(db_name, self.arango.databases["all"])
# Check the properties of the new database
self.assertEqual(self.arango.db(db_name).name, db_name)
self.assertEqual(self.arango.db(db_name).is_system, False)
# Remove the test database
self.arango.remove_database(db_name)
self.assertNotIn(db_name, self.arango.databases["all"])
def test_database_properties(self):
db = self.arango.database("_system")
self.assertEqual(db.name, "_system")
self.assertTrue(isinstance(db.properties, dict))
self.assertTrue(is_string(db.id))
self.assertTrue(is_string(db.path))
self.assertEqual(db.is_system, True)
示例3: Arango
# 需要导入模块: from arango import Arango [as 别名]
# 或者: from arango.Arango import database [as 别名]
#! /usr/bin/env python
import ujson
import fileinput
import arango
from arango import Arango
from pprint import pprint
dbcnx = Arango(host="localhost")
try:
dbcnx.delete_database("eris0")
except arango.exceptions.DatabaseDeleteError:
pass
dbcnx.create_database("eris0")
db = dbcnx.database("eris0")
db.create_collection("events")
col = db.collection("events")
col.wait_for_sync = False
def main():
for line in fileinput.input():
line = line.strip()
event = None
try:
event = ujson.loads(line)
except ValueError:
continue
event["_key"] = event["id"]
del event["id"]
col.create_document(event)
示例4: Arango
# 需要导入模块: from arango import Arango [as 别名]
# 或者: from arango.Arango import database [as 别名]
from arango import Arango
a = Arango(host="localhost", port=8529, username='root', password='joker')
db = a.database("technodeminer")