문제

I am using this api.. whose function call looks like:

g.vertices.index.lookup(identifier="value")

Now note that idenitifier is a variable which I have not defined but is resoluted by api and value is a string.

Something similar happens in pymongo api: http://api.mongodb.org/python/current/tutorial.html

db = client.test_database

is equal to

db = client["test_database"]

test_database in first case, even though user hasnt defined that variable.. but is understood by mongo that in my datastore, do i have a database called test_database or not..

Now, the issue I have is this: I have a colon in my datastore..

Which is to say it is like:

g.vertices.index.lookup(bad:identifier="value")

See.. the colon in the query..

And this api doesnt have that mongo type dictionary implementation..

I know, I should resolve this as in why I am getting this colon.. but this is what I am stuck at right now..

And the issue is because of that colon, I get

g.vertices.index.lookup(bad:identifier="value")
                           ^
SyntaxError: invalid syntax

How do i resolve this

도움이 되었습니까?

해결책

g.vertices.index.lookup(**{"bad:identifier":"value"})

may work ... this is known as unpacking keyword arguments

다른 팁

In Bulbs, index.lookup(key=value) is just syntactic sugar for index.lookup(key, value) so you could simply do this:

>>> g.vertices.index.lookup("bad:identifier", "value")

You didn't indicate which graph database server you are using (Neo4j Server, Rexster, or Titan), but the syntax is the same for each. See...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top