neomodel 访问 neo4j 最后出现的错误

Exception TypeError: "'NoneType' object is not callable" in <bound method Connection.__del__ of <neo4j.bolt.connection.Connection object at 0x7fd4c7420110>> ignored
Exception TypeError: TypeError("'NoneType' object is not callable",) in <bound method DirectDriver.__del__ of <neo4j.v1.direct.DirectDriver object at 0x7fd4c7410dd0>> ignored
Exception TypeError: "'NoneType' object is not callable" in <bound method Connection.__del__ of <neo4j.bolt.connection.Connection object at 0x7fd4c7410f50>> ignored

应用场景是构造自己的查询语句:

from neomodel import db

    # query = 'MATCH (a:Source{name: {n0}}) RETURN a.name, a.titleid'
    # results, columns = db.cypher_query(query, {'n0': '干旱'})
    #
    # for row in results:
    #     print str(row[0]), str(row[1])
    #
    # db.driver.close()

解决办法: db.driver.close(),当然在什么地方增加也是有说的,如果是循环中加入会报如下错误:

Traceback (most recent call last):
  File "/home/py/PycharmProjects/ThirdTest/questionanswer/neo4joperate.py", line 153, in <module>
    get_question_id(query, params_json_string)
  File "/home/py/PycharmProjects/ThirdTest/questionanswer/neo4joperate.py", line 127, in get_question_id
    results, columns = db.cypher_query(query_string, params_json_string)
  File "/usr/local/lib/python2.7/dist-packages/neomodel/util.py", line 28, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/neomodel/util.py", line 95, in cypher_query
    session = self.driver.session()
  File "/usr/local/lib/python2.7/dist-packages/neo4j/v1/direct.py", line 67, in session
    return BoltSession(self._pool.acquire, self._max_retry_time, access_mode=access_mode, bookmark=bookmark)
AttributeError: 'NoneType' object has no attribute 'acquire'

所以不能放在循环中。

原文地址:https://www.cnblogs.com/herosoft/p/7905147.html