本文整理匯總了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")