pyorient
pyorient copied to clipboard
query() got an unexpected keyword argument
pyorient==1.5.5
import pyorient.ogm
from pyorient.ogm import Graph, Config, declarative
from pyorient.ogm.property import *
# Initialize Registries
Node = declarative.declarative_node()
Relationship = declarative.declarative_relationship()
server = "localhost"
db_name = "mygraph"
db_admin = "root"
db_admin_password = "root"
port = 2424
class Person(Node):
id = String(unique = True)
name = String()
pass
class Friend(Relationship):
pass
if __name__ == "__main__":
print('Hello')
client = pyorient.OrientDB(server, port)
session_id = client.connect(db_admin, db_admin_password)
if not client.db_exists(db_name, pyorient.STORAGE_TYPE_PLOCAL):
client.db_create(db_name, pyorient.DB_TYPE_GRAPH, pyorient.STORAGE_TYPE_PLOCAL)
ret = client.db_open(db_name, db_admin, db_admin_password)
graph = Graph(Config.from_url(server+":"+str(port)+"/"+db_name, db_admin, db_admin_password))
graph.clear_registry()
graph.create_all(Node.registry)
graph.create_all(Relationship.registry)
graph.include(Node.registry)
graph.include(Relationship.registry)
graph.create_vertex(Person, id = '1000', name='Prakash')
data = client.query("SELECT FROM Person WHERE id = '1000'")
print(data)
results = graph.query(Person, name='Prakash')
print(results)
prints
/home/cegprakash/.virtualenvs/cegprakash-6Wq6Rd61/bin/python /home/cegprakash/workspace/janusgraph_test/janusgraph_test/main.py
Hello
[<pyorient.otypes.OrientRecord object at 0x7f0b2aef70b8>]
Traceback (most recent call last):
File "/home/cegprakash/workspace/janusgraph_test/janusgraph_test/main.py", line 53, in <module>
results = graph.query(Person, name='Prakash')
TypeError: query() got an unexpected keyword argument 'name'
Process finished with exit code 1
https://stackoverflow.com/questions/51703057/pyorient-querying-a-vertex-in-orientdb
there is already the answer :https://github.com/mogui/pyorient/issues/236
Look at the comment https://github.com/mogui/pyorient/issues/274#issuecomment-481025944 for an example of how to use the OGM broker to query.