当前位置: 首页>>代码示例>>Python>>正文


Python GraphDatabase.shutdown方法代码示例

本文整理汇总了Python中neo4j.GraphDatabase.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Python GraphDatabase.shutdown方法的具体用法?Python GraphDatabase.shutdown怎么用?Python GraphDatabase.shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在neo4j.GraphDatabase的用法示例。


在下文中一共展示了GraphDatabase.shutdown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MetaInfoCreator

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
class MetaInfoCreator( object ):
	def __init__( self, databasePath, datasetDict):

		#increment to existing db
		self.db = GraphDatabase( databasePath )
		self.datasetDict = datasetDict

	def start(self):
		self._createInfoNodes()
		self._finish()

	def _createInfoNodes( self ):
		print "Creating info nodes"
		# do all insertions within one transaction: complete failure or success!
		with self.db.transaction:
			metaVertex = self.db.node() #self.db.reference_node
			print "Meta node created, id %i" %( metaVertex.id )
			index = self.db.node.indexes.create('meta')
			index['meta']['meta'] = metaVertex

			for num, (label, patientFile) in enumerate( self.datasetDict.items() ):
				patientFile = open( patientFile, 'r')
				patientFile.readline() #header

				datasetVertex = self.db.node()
				datasetVertex['datalabel'] = label
				datasetVertex['barcode'] = patientFile.readline().strip("\n")

				metaVertex.relationships.create('DATASET', datasetVertex, label=label)
				patientFile.close()

	def _finish(self):
		self.db.shutdown()
		print "Infonodes created" 
开发者ID:amergin,项目名称:neo4j-import,代码行数:36,代码来源:create_info_nodes.py

示例2: showAllDB

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
def showAllDB():
	db = GraphDatabase(workingdb)

	query = """START n=node(*)
				MATCH (n) - [r] -> (m)
				RETURN n.name, r, m.name"""

	print db.query(query)

	db.shutdown()
开发者ID:silvia6200,项目名称:humeanhackers,代码行数:12,代码来源:NeoCreate.py

示例3: get_rel_info

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
def get_rel_info(dbname,relid):        
    from neo4j import GraphDatabase
    from neo4j import OUTGOING, INCOMING, ANY
    db = GraphDatabase(dbname)
    relid = int(relid) #make sure it is an int
    rel = db.relationship[relid]
    print rel
    for key,value in rel.items():
        print "\t"+key,value
    db.shutdown()
开发者ID:OpenTreeOfLife,项目名称:gcmdr,代码行数:12,代码来源:general_utils.py

示例4: get_node_info

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
def get_node_info(dbname,nodeid):
    from neo4j import GraphDatabase
    from neo4j import OUTGOING, INCOMING, ANY
    db = GraphDatabase(dbname)
    nodeid = int(nodeid) #make sure it is an int
    nd = db.node[nodeid]
    print nd
    for key,value in nd.items():
        print "\t"+key,value
        if "uniqname" in str(key):
            break
    db.shutdown()
开发者ID:OpenTreeOfLife,项目名称:gcmdr,代码行数:14,代码来源:general_utils.py

示例5: showAllRelations

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
def showAllRelations(qname):
	db = GraphDatabase(workingdb)


	query = """START n=node(*)
			   MATCH (n) - [r] -> (m)
			   WHERE HAS(n.name) AND n.name = {name}
			   RETURN n.name, r, m.name"""

	print db.query(query, name=qname)


	db.shutdown()
开发者ID:silvia6200,项目名称:humeanhackers,代码行数:15,代码来源:NeoCreate.py

示例6: test_create_configured_db

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
 def test_create_configured_db(self):
     folder_to_put_db_in = tempfile.mkdtemp()
     try:
         # START SNIPPET: creatingConfiguredDatabase
         from neo4j import GraphDatabase
         
         # Example configuration parameters
         db = GraphDatabase(folder_to_put_db_in, string_block_size=200, array_block_size=240)
         
         db.shutdown()
         # END SNIPPET: creatingConfiguredDatabase
     finally:
        if os.path.exists(folder_to_put_db_in):
           import shutil
           shutil.rmtree(folder_to_put_db_in)
开发者ID:Brackets,项目名称:neo4j,代码行数:17,代码来源:core.py

示例7: test_create_db

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
 def test_create_db(self):
     folder_to_put_db_in = tempfile.mkdtemp()
     try:
         # START SNIPPET: creatingDatabase
         from neo4j import GraphDatabase
         
         # Create db
         db = GraphDatabase(folder_to_put_db_in)
         
         # Always shut down your database
         db.shutdown()
         # END SNIPPET: creatingDatabase
     finally:
        if os.path.exists(folder_to_put_db_in):
           import shutil
           shutil.rmtree(folder_to_put_db_in)
开发者ID:Brackets,项目名称:neo4j,代码行数:18,代码来源:core.py

示例8: showAllNodes

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
def showAllNodes():

	# open the db
	db = GraphDatabase(workingdb)

	number_of_nodes = len(db.nodes)
	query = "START n=node(*) RETURN n"

	print "This db has " + str(number_of_nodes) +"nodes" 
	
	if(number_of_nodes>0):

		print db.query(query)
	else: 
		print "no nodes"
	
	db.shutdown()
开发者ID:silvia6200,项目名称:humeanhackers,代码行数:19,代码来源:NeoCreate.py

示例9: get_nodeinfo_for_name

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
def get_nodeinfo_for_name(dbname,name):
    from neo4j import GraphDatabase
    from neo4j import OUTGOING, INCOMING, ANY
    db = GraphDatabase(dbname)
    with db.transaction:
        node_idx = db.node.indexes.get('graphNamedNodes')
        hits = node_idx['name'][name]
        for i in hits:
            print i
            for key,value in i.items():
                print "\t"+key,value
                #printing after, prints mrcas which are usually too long
                #comment to let it go, but don't commit
                if "uniqname" in str(key):
                    break
        hits.close()
    db.shutdown()
开发者ID:OpenTreeOfLife,项目名称:gcmdr,代码行数:19,代码来源:general_utils.py

示例10: __init__

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
class NeoCreator:
    def __init__(self,path):
        self.db = GraphDatabase(path)
        
    def shutdown(self):
        self.db.shutdown()
        
    def createNewNode(self,_id,nick):
        with self.db.transaction:
            newNode = self.db.node(uid=_id,Label=nick)
            if newNode is None:
                raise
            
        return newNode
    
    def createRelationship(self,origin,destiny):
        with self.db.transaction:
            origin.tweets(destiny,Label="tweets")
开发者ID:MichaelMarkieta,项目名称:twitterstream-to-mongodb,代码行数:20,代码来源:graphextractor.py

示例11: addUser

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
def addUser(usuario):
    
    # Create a database
    db = GraphDatabase('/tmp/')
    user_idx = db.node.indexes.get('users')
    cafe_idx = db.node.indexes.get('cafes')

    # All write operations happen in a transaction
    with db.transaction:
        firstNode = db.node(name=usuario, type_record='user')
        user_idx['name'][usuario] = firstNode

        secondNode = cafe_idx['name']['lungo'].single
 
        # Create a relationship with type 'knows'
        relationship = firstNode.toma(secondNode, cantidad=3) 
 
    # Always shut down your database when your application exits
    db.shutdown()
开发者ID:borillo,项目名称:hacknight-neo4j-gevent,代码行数:21,代码来源:server.py

示例12: main

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
def main():
    
    global db

    try:
        shutil.rmtree('benchmark_db')
    except:
        pass
    db = GraphDatabase('benchmark_db')
    repetitions = 10
    count = 1000

    transaction_benchmark(repetitions)
    node_benchmark(repetitions,count)
    relation_benchmark(repetitions,count)
    traversal_benchmark(repetitions,count)
    indexing_benchmark(repetitions,count)
    lookup_benchmark(repetitions,count)

    db.shutdown()
开发者ID:HeinrichHartmann,项目名称:neo4j-python-benchmark,代码行数:22,代码来源:neo4j_benchmark.py

示例13: addtodb

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
def addtodb(lnode, rnode, relationship):
	# Create a database
	db = GraphDatabase(workingdb)
	#	rel['subjsym'], rel['objsym'], rel['filler'] 

	with db.transaction:
		
		lnodef = False	#lnodef and rnodef store whether the node has been found in the db
		rnodef = False
		for node in db.nodes:
				for key, value in node.items():
					if (key == "name"):
						if(value == lnode):
							leftnode = node
							lnodef = True	
						if(value == rnode):
							rightnode = node
							rnodef = True

		if (not lnodef):
			leftnode = db.node(name=(lnode))
			print "Lnode " + lnode + "created"

		if (not rnodef):
			rightnode = db.node(name=(rnode))
			print "Rnode " + rnode + "created"

		relf = False
		for rel in leftnode.relationships.outgoing:
			for key, value in rel.items():
				if (str(rel.type) == relationship and key == 'hits'and rel.end == rightnode):
					rel[key] = value + 1
					relf = True
					print "rel  found. Increasing number of hits "
		if (not relf):
			rel = leftnode.relationships.create(relationship, rightnode)
			print "created relationship " + relationship
			rel['hits'] = 1

		
	db.shutdown()
开发者ID:silvia6200,项目名称:humeanhackers,代码行数:43,代码来源:NeoCreate.py

示例14: test_hello_world

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
    def test_hello_world(self):
        folder_to_put_db_in = tempfile.mkdtemp()
        try:
            # START SNIPPET: helloworld
            from neo4j import GraphDatabase

            # Create a database
            db = GraphDatabase(folder_to_put_db_in)

            # All write operations happen in a transaction
            with db.transaction:
                firstNode = db.node(name="Hello")
                secondNode = db.node(name="world!")

                # Create a relationship with type 'knows'
                relationship = firstNode.knows(secondNode, name="graphy")

            # Read operations can happen anywhere
            message = " ".join([firstNode["name"], relationship["name"], secondNode["name"]])

            print message

            # Delete the data
            with db.transaction:
                firstNode.knows.single.delete()
                firstNode.delete()
                secondNode.delete()

            # Always shut down your database when your application exits
            db.shutdown()
            # END SNIPPET: helloworld
        finally:
            if os.path.exists(folder_to_put_db_in):
                import shutil

                shutil.rmtree(folder_to_put_db_in)

        self.assertEqual(message, "Hello graphy world!")
开发者ID:brownscott,项目名称:neo4j,代码行数:40,代码来源:examples.py

示例15: VcwebGraphDatabase

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import shutdown [as 别名]
class VcwebGraphDatabase(object):

    _db = None

    @property
    def db(self):
        return self._db

    def get_db(self, data_dir=None):
        from neo4j import GraphDatabase
        if self._db is None:
            if data_dir is None:
                data_dir = settings.GRAPH_DATABASE_PATH
            self._db = GraphDatabase(data_dir)
        db = self._db
        return self._db

    def shutdown(self):
        if self._db is not None:
            self._db.shutdown()
            self._db = None

    def link(self, group, number=5):
        db = self.get_db()
开发者ID:tgpatel,项目名称:vcweb,代码行数:26,代码来源:graph.py


注:本文中的neo4j.GraphDatabase.shutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。