questions + issues: record_create do not create record, client.command cannot be put in transactions
here doing test of this py driver.
A couple of issues (see at the bottom) prevent me to populate my class. I also add a few questions, for improving documentation (and my understanding :+1: )
- Global variables client.db_create(db_name, pyorient.DB_TYPE_GRAPH, pyorient.STORAGE_TYPE_MEMORY ) will create the graph in memory, instead in the documentaiton I understood would be bettwe in PLOCAL. Where is a list of global settings of pyorient?
- how to access the result of a command ?
<pyorient.messages.records.RecordCreateMessage object at 0x104f8b5d0> - I created a class, say "Topic", which command to get the name, id, properties of a class?
- testing record insertion rec = { '@Topic': {'name': 'Computer accessibility', 'idSource': 20}} cluster_id = 11 #check TODO how to get it!? client.record_create(11, rec )
it looks to have include it (no error), but I look at the web console in orient, it is not.
Not that I included a couple of constraint to avoid duplication
client.command("CREATE INDEX Topic.idSource ON Topic (idSource) Unique")
but if I repeat the command, it won't give any error - although, it won't include the record as well.
- testing transaction and batch transaction
I am trying:
tx.begin() for item in block: k = item.replace('\n','').split('\t')[0] v = item.replace('\n','').split('\t')[1] q=client.command("CREATE VERTEX Topic SET name = \'"+k+"\', idSource = "+v) tx.attach(q) tx.commit()
but
Traceback (most recent call last): File "<stdin>", line 10, in <module> File "pyorient/messages/commands.py", line 529, in attach self._transaction.attach( operation ) File "pyorient/messages/commands.py", line 458, in attach "Wrong command type " + operation.__class__.__name__, [] pyorient.exceptions.PyOrientBadMethodCallException: Wrong command type CommandMessage
- Which is best way to do a batch import? I am using python for this task, I putting a tx inside a loop, attach some commands, and then commit, and over again. Or should i use the batch you were pointing in the wiki?
- I see pyOrient is official, but looks the one in javascript is a bit better documented in the wiki, and looks more extensive. Are the drivers capable of same functions ? Do you plan guys to even out the wiki between the drivers ?
Thank you, and.. maybe, more to follow :dancer:
@gg4u, you can obtain cluster information from the class instance returned by pyorient.orient.OrientDB.db_open:
import pyorient
client = pyorient.OrientDB('localhost', 2424)
info = client.db_open('GratefulDeadConcerts', 'username', 'passwd')
print info.dataClusters
Running a query via client.command() or client.query() should return a list of pyorient.types.OrientRecord instances (at least with the latest pyorient code from GitHub); check the oRecordData attribute of these instances for the data extracted from the database.
Hi @lebedov ,
tx = client.tx_commit() tx.begin() q=client.command("CREATE VERTEX Topic SET name = 'name', idSource = 10") tx.attach(q)
results in:
tx.attach(q) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pyorient/messages/commands.py", line 529, in attach self._transaction.attach( operation ) File "pyorient/messages/commands.py", line 458, in attach "Wrong command type " + operation.__class__.__name__, [] pyorient.exceptions.PyOrientBadMethodCallException: Wrong command type CommandMessage
I also would like to check the property as you said:
hasattr(q, 'oRecordData')
returns
false
You can't use the command method in a transaction; you need to use record_create, record_update, or record_delete.
Hi @gg4u ,
thank you @lebedov , you're right. In the OrientDB binary protocol ( and in pyorient of course ), inside the transactions only the CRUD methods are supported.