本文整理汇总了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"
示例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()
示例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()
示例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()
示例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()
示例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)
示例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)
示例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()
示例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()
示例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")
示例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()
示例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()
示例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()
示例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!")
示例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()