python - OrientDB issue creating vertex in transaction -
i think there problem when creating records in graph using transactions. vertices created during transaction stored in cluster #3, when check on studio webapp vertex created in tx has class 'unknown'
here code:
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() # returns 'dummy' , 'another_me', people created in tx not present res = client.command("select 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'} # ones created in transaction found in cluster #3, no class print(client.command("select #3:0")[0]) => {{'name': 'me', 'age': 30},'version':1,'rid':'#3:0'}
i have activated debug option in xml config, , log doesn't give information:
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 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 int (4 bytes)... [ochannelbinaryserver]
the pyorient docs have following example (with few lines removed clarity)...
tx = client.tx_commit() tx.begin() # create new record rec1 = { 'accommodation': 'home', 'work': 'some work', 'holiday': 'surf' } rec_position1 = client.record_create( -1, rec1 ) tx.attach( rec_position1 )
the source code record_create follows...
def record_create(self, *args): return self.get_message("recordcreatemessage") \ .prepare(args).send().fetch_response()
your code running get_message
, prepare
functions, not send
, fetch_response
. suspect problem lies.
Comments
Post a Comment