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)
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)
def connect_to_arango(): a = Arango(host=ARANGO_HOSTNAME, port=ARANGO_PORT, username='******', password='******') try: user_info = dict() user_info['username'] = '******' user_info['passwd'] = 'joker' user_info['active'] = True db = a.create_database(ARANGODB_NAME, users=[user_info]) return db except: db = a.database(ARANGODB_NAME) return db
def load_into_arango(author_file="/media/sf_Data/AMiner/AMiner-Author.txt", coauthor_file="/media/sf_Data/AMiner/AMiner-Coauthor.txt"): print "Connecting to arango" a = Arango(host="localhost", port=8529, username='******', password='******') try: user_info = dict() user_info['username'] = '******' user_info['passwd'] = 'joker' user_info['active'] = True db = a.create_database("aminer", users=[user_info]) except: db = a.database("aminer") try: graph = db.create_graph("aminer_coauthors") except: graph = db.graph("aminer_coauthors") try: db.create_collection("authors") graph.create_vertex_collection("authors") db.create_collection("coauthors", is_edge=True) graph.create_edge_definition(edge_collection="coauthors", from_vertex_collections=["authors"], to_vertex_collections=["authors"]) except: pass print "Reading AMiner Data" authors, coauthor_relations = get_author_coauthors(author_file, coauthor_file) print "Loading authors into arango" for key in authors: graph.create_vertex("authors", authors[key]) print "Building coauthor relations" for author in coauthor_relations.keys(): for rel in coauthor_relations[author]: graph.create_edge("coauthors", {"_from": "authors/" + unicode(author), "_to": "authors/"+ unicode(rel[0]), "w": rel[1]})
#! /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)
from arango import Arango a = Arango(host="localhost", port=8529, username='******', password='******') db = a.database("technodeminer")
from werkzeug.security import generate_password_hash, check_password_hash from arango import Arango a = Arango(host="localhost", port=8529, username='******', password='******') db = a.database("aminer")