Domanda

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

È stato utile?

Soluzione

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

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

Altri suggerimenti

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...

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top