吹扫代码是对以下内容的微小修改:https://www.arangodb.com/tutorials/tutorial-python/
doc = {"_key": 'some_nice_key', "name": 'Robert', "age": '56'}
bindVars = {"doc": doc,"collection":"test"}
aql = "INSERT @doc INTO @collection LET newDoc = NEW RETURN newDoc"
queryResult = db.AQLQuery(aql, bindVars = bindVars)
我只是做了一些修改:
{"doc": doc} -> {"doc": doc,"collection":"test"}
INSERT @doc INTO users... -> INSERT @doc INTO @collection...
它给了我错误:
bind parameter 'bind parameter 'collection' has an invalid value or type near '@collection LET newDoc = NEW RET...' at position 1:18' has an invalid value or type (while parsing). Errors: {u'code': 400, u'errorNum': 1553, u'errorMessage': u"bind parameter 'bind parameter 'collection' has an invalid value or type near '@collection LET newDoc = NEW RET...' at position 1:18' has an invalid value or type (while parsing)", u'error': True}
aql不支持动态集合吗?我犯了什么错误?
1条答案
按热度按时间tquggr8v1#
AQL支持注入集合名称。但这是一种特殊情况,您必须使用额外的
@
作为前缀。https://docs.arangodb.com/3.11/aql/fundamentals/bind-parameters/通过这些修改,您的代码应该可以工作: