'Session' 对象没有属性 'session'
'Session' object has no attribute 'session'
我收到一条错误消息
这是我的代码块(经过简化,但仍然显示错误)
import neo4j
import sys
import uuid
from neo4j import GraphDatabase
def create_population_point(tx, _point, _uuid, _tl, _tr, _ll, _lr, _band):
print("Add a record block A")
tx.run("CREATE (n:Population_Point
{point:$point,uuid:$uuid,TL:$tl,TR:$tr,BL:$bl,BR:$br,Band_1:$band}),"
"point=_point,uuid=_uuid,tl=_tl,tr=_tr,ll=_ll,lr=_lr,band=_band")
def main():
uri = "neo4j://localhost:7687"
username = "neo4j"
password = "P@ssword2"
databaseConnection = GraphDatabase.driver(uri, auth=(username, password))
databaseSession = databaseConnection.session()
print("Connection established")
print("Variables assigned values")
_point = "D007_S001_T001"
_uuid = uuid.uuid4()
_tl = "28.27291"
_tr = "-81.65765"
_ll = "28.27291"
_lr = "-81.65765"
_band = "455"
print("Ready to execute")
with databaseSession.session() as session:
result = session.write_transaction(create_population_point, _point, _uuid, _tl, _tr, _ll,
_lr, _band)
databaseConnection.close()
print("Connection closed")
if __name__ == "__main__":
main()
这是抛出错误的行
以 databaseSession.session() 作为会话:
运行 python 3.10.4
首先你创建
databaseSession = databaseConnection.session()
下次使用
with databaseSession.session() as session:
所以最后你尝试使用
databaseConnection.session().session()
这是错误的。
可以直接使用
result = databaseSession.write_transaction(..)
或在
中使用databaseConnection
代替databaseSession
with databaseConnection.session() as session:
result = session.write_transaction(..)
(并删除 databaseSession = databaseConnection.session()
因为你不使用它)
我收到一条错误消息
这是我的代码块(经过简化,但仍然显示错误)
import neo4j
import sys
import uuid
from neo4j import GraphDatabase
def create_population_point(tx, _point, _uuid, _tl, _tr, _ll, _lr, _band):
print("Add a record block A")
tx.run("CREATE (n:Population_Point
{point:$point,uuid:$uuid,TL:$tl,TR:$tr,BL:$bl,BR:$br,Band_1:$band}),"
"point=_point,uuid=_uuid,tl=_tl,tr=_tr,ll=_ll,lr=_lr,band=_band")
def main():
uri = "neo4j://localhost:7687"
username = "neo4j"
password = "P@ssword2"
databaseConnection = GraphDatabase.driver(uri, auth=(username, password))
databaseSession = databaseConnection.session()
print("Connection established")
print("Variables assigned values")
_point = "D007_S001_T001"
_uuid = uuid.uuid4()
_tl = "28.27291"
_tr = "-81.65765"
_ll = "28.27291"
_lr = "-81.65765"
_band = "455"
print("Ready to execute")
with databaseSession.session() as session:
result = session.write_transaction(create_population_point, _point, _uuid, _tl, _tr, _ll,
_lr, _band)
databaseConnection.close()
print("Connection closed")
if __name__ == "__main__":
main()
这是抛出错误的行
以 databaseSession.session() 作为会话:
运行 python 3.10.4
首先你创建
databaseSession = databaseConnection.session()
下次使用
with databaseSession.session() as session:
所以最后你尝试使用
databaseConnection.session().session()
这是错误的。
可以直接使用
result = databaseSession.write_transaction(..)
或在
中使用databaseConnection
代替databaseSession
with databaseConnection.session() as session:
result = session.write_transaction(..)
(并删除 databaseSession = databaseConnection.session()
因为你不使用它)