OrientDB在事务中创建顶点问题

2024-09-27 19:27:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我认为使用事务在图表中创建记录时会出现问题。 在事务期间创建的顶点总是存储在集群3中,当我检查studio webapp时,在tx中创建的顶点的类为“Unknown”

代码如下:

client = pyorient.OrientDB("localhost", 2424)
client.connect("xxx", "xxx")
client.db_open("admin", "admin")

people_cluster = client.command("create class People extends V")
client.command("create vertex People content {'name': 'dummy', 'age': 21}")

attrs = {'@People': {'name': 'another_me', 'age': 31}}
res = client.record_create(people_cluster[0], attrs)

attrs2 = {'@People': {'name': 'me', 'age': 30}}
create_rec_cmd = ( client.get_message(pyorient.RECORD_CREATE) ).prepare((people_cluster[0], attrs2))

tx = tx.commit()
tx.begin()
tx.attach(create_rec_cmd)
tx.commit()

# This returns 'dummy' and 'another_me', but the people created in the tx is not present
res = client.command("select from People")

print(res[0]) => {'@People':{'age': 21, 'name': 'dummy', 'version':2,'rid':'#13:0'}
print(res[1]) => {'@People':{'age': 31, 'name': 'another_me'},'version':1,'rid':'#13:1'}

# The ones created in the transaction are found in the cluster #3, but with no class
print(client.command("select from #3:0")[0]) => {{'name': 'me', 'age': 30},'version':1,'rid':'#3:0'}

我在xml配置中激活了debug选项,日志中没有提供太多信息:

2015-08-16 17:59:46:992 INFO {db=test} /192.168.10.1:41317 - Read byte: 60 [OChannelBinaryServer]

2015-08-16 17:59:46:994 INFO {db=test} /192.168.10.1:41317 - Reading int (4 bytes)... [OChannelBinaryServer]

2015-08-16 17:59:46:995 INFO {db=test} /192.168.10.1:41317 - Read int: 6 [OChannelBinaryServer]

2015-08-16 17:59:47:000 INFO {db=test} /192.168.10.1:41317 - Reading int (4 bytes)... [OChannelBinaryServer]

2015-08-16 17:59:47:002 INFO {db=test} /192.168.10.1:41317 - Read int: 2113677732 [OChannelBinaryServer]

2015-08-16 17:59:47:003 INFO {db=test} /192.168.10.1:41317 - Reading byte (1 byte)... [OChannelBinaryServer]

2015-08-16 17:59:47:004 INFO {db=test} /192.168.10.1:41317 - Read byte: 1 [OChannelBinaryServer]

2015-08-16 17:59:47:005 INFO {db=test} /192.168.10.1:41317 - Reading byte (1 byte)... [OChannelBinaryServer]

2015-08-16 17:59:47:006 INFO {db=test} /192.168.10.1:41317 - Read byte: 1 [OChannelBinaryServer]

2015-08-16 17:59:47:006 INFO {db=test} /192.168.10.1:41317 - Reading byte (1 byte)... [OChannelBinaryServer]

2015-08-16 17:59:47:007 INFO {db=test} /192.168.10.1:41317 - Read byte: 3 [OChannelBinaryServer]

2015-08-16 17:59:47:007 INFO {db=test} /192.168.10.1:41317 - Reading short (2 bytes)... [OChannelBinaryServer]

2015-08-16 17:59:47:007 INFO {db=test} /192.168.10.1:41317 - Read short: -1 [OChannelBinaryServer]

2015-08-16 17:59:47:008 INFO {db=test} /192.168.10.1:41317 - Reading long (8 bytes)... [OChannelBinaryServer]

2015-08-16 17:59:47:008 INFO {db=test} /192.168.10.1:41317 - Read long: -2 [OChannelBinaryServer]

2015-08-16 17:59:47:009 INFO {db=test} /192.168.10.1:41317 - Reading byte (1 byte)... [OChannelBinaryServer]

2015-08-16 17:59:47:009 INFO {db=test} /192.168.10.1:41317 - Read byte: 100 [OChannelBinaryServer]

2015-08-16 17:59:47:010 INFO {db=test} /192.168.10.1:41317 - Reading chunk of bytes. Reading chunk length as int (4 bytes)... [OChannelBinaryServer]

2015-08-16 17:59:47:010 INFO {db=test} /192.168.10.1:41317 - Read chunk lenght: 18 [OChannelBinaryServer]

2015-08-16 17:59:47:011 INFO {db=test} /192.168.10.1:41317 - Reading 18 bytes... [OChannelBinaryServer]

2015-08-16 17:59:47:011 INFO {db=test} /192.168.10.1:41317 - Read 18 bytes: age:30,name:"me" [OChannelBinaryServer]

2015-08-16 17:59:47:016 INFO {db=test} /192.168.10.1:41317 - Reading byte (1 byte)... [OChannelBinaryServer]

2015-08-16 17:59:47:017 INFO {db=test} /192.168.10.1:41317 - Read byte: 0 [OChannelBinaryServer]

2015-08-16 17:59:47:017 INFO {db=test} /192.168.10.1:41317 - Reading chunk of bytes. Reading chunk length as int (4 bytes)... [OChannelBinaryServer]


Tags: nametestinfoclientreaddbagebytes
1条回答
网友
1楼 · 发布于 2024-09-27 19:27:11

pyorient docs有以下示例(为了清楚起见,删除了一些行)。。。在

tx = client.tx_commit()
tx.begin()

# create a new record
rec1 = { 'accommodation': 'home', 'work': 'some work', 'holiday': 'surf' }
rec_position1 = client.record_create( -1, rec1 )

tx.attach( rec_position1 )

record_create的源代码如下。。。在

^{pr2}$

您的代码只运行get_messageprepare函数,而不是send和{}。我想这就是你的问题所在。在

相关问题 更多 >

    热门问题