我认为使用交易在图表中创建记录时会出现问题。 在事务期间创建的顶点始终存储在集群#3中,当我检查studio webapp时,在tx中创建的顶点具有类“未知”
以下是代码:
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配置中激活了调试选项,并且日志没有提供太多信息:
2015-08-16 17:59:46:992 INFO {db = test} /192.168.10.1:41317 - 读取字节:60 [OChannelBinaryServer]
2015-08-16 17:59:46:994 INFO {db = test} /192.168.10.1:41317 - 读取int(4字节)... [OChannelBinaryServer]
2015-08-16 17:59:46:995 INFO {db = test} /192.168.10.1:41317 - 阅读int:6 [OChannelBinaryServer]
2015-08-16 17:59:47:000 INFO {db = test} /192.168.10.1:41317 - 阅读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 - 读取字节(1个字节)... [OChannelBinaryServer]
2015-08-16 17:59:47:004 INFO {db = test} /192.168.10.1:41317 - 读取字节:1 [OChannelBinaryServer]
2015-08-16 17:59:47:005 INFO {db = test} /192.168.10.1:41317 - 读取字节(1个字节)... [OChannelBinaryServer]
2015-08-16 17:59:47:006 INFO {db = test} /192.168.10.1:41317 - 读取字节:1 [OChannelBinaryServer]
2015-08-16 17:59:47:006 INFO {db = test} /192.168.10.1:41317 - 读取字节(1个字节)... [OChannelBinaryServer]
2015-08-16 17:59:47:007 INFO {db = test} /192.168.10.1:41317 - 读取字节:3 [OChannelBinaryServer]
2015-08-16 17:59:47:007 INFO {db = test} /192.168.10.1:41317 - 读短(2字节)... [OChannelBinaryServer]
2015-08-16 17:59:47:007 INFO {db = test} /192.168.10.1:41317 - 阅读简短:-1 [OChannelBinaryServer]
2015-08-16 17:59:47:008 INFO {db = test} /192.168.10.1:41317 - 读长(8字节)... [OChannelBinaryServer]
2015-08-16 17:59:47:008 INFO {db = test} /192.168.10.1:41317 - 读长:-2 [OChannelBinaryServer]
2015-08-16 17:59:47:009 INFO {db = test} /192.168.10.1:41317 - 读取字节(1个字节)... [OChannelBinaryServer]
2015-08-16 17:59:47:009 INFO {db = test} /192.168.10.1:41317 - 读取字节:100 [OChannelBinaryServer]
2015-08-16 17:59:47:010 INFO {db = test} /192.168.10.1:41317 - 读取大块字节。读取块长度为int(4字节)... [OChannelBinaryServer]
2015-08-16 17:59:47:010 INFO {db = test} /192.168.10.1:41317 - 阅读chunk lenght:18 [OChannelBinaryServer]
2015-08-16 17:59:47:011 INFO {db = test} /192.168.10.1:41317 - 读取18个字节... [OChannelBinaryServer]
2015-08-16 17:59:47:011 INFO {db = test} /192.168.10.1:41317 - 读取18个字节:年龄:30,名称:“me”[OChannelBinaryServer]
2015-08-16 17:59:47:016 INFO {db = test} /192.168.10.1:41317 - 读取字节(1个字节)... [OChannelBinaryServer]
2015-08-16 17:59:47:017 INFO {db = test} /192.168.10.1:41317 - 读取字节:0 [OChannelBinaryServer]
2015-08-16 17:59:47:017 INFO {db = test} /192.168.10.1:41317 - 读取大块字节。读取块长度为int(4字节)... [OChannelBinaryServer]
答案 0 :(得分:0)
pyorient docs有以下示例(为清晰起见删除了几行)...
globalController
record_create的源代码如下......
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 )
您的代码仅运行def record_create(self, *args):
return self.get_message("RecordCreateMessage") \
.prepare(args).send().fetch_response()
和get_message
个功能,但不运行prepare
和send
。我怀疑这是你的问题所在。