Star

可以使用带参数的查询吗

类似其他数据库构造带参数的查询语句,sql = “select id from users where username=@username and password=@password”;

可以的,比如

nebula> GO FROM 100 OVER follow REVERSELY YIELD follow._dst AS id | \
        GO FROM $-.id OVER serve WHERE $^.player.age > 20 YIELD $^.player.name AS FriendOf, $$.team.name AS Team;

============================
| FriendOf      | Team     |
============================
| Tony Parker   | Warriors |
----------------------------
| Kyle Anderson | Warriors |
----------------------------

文档见
https://docs.nebula-graph.com.cn/manual-CN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/go-syntax/

1赞

这种只适用于管道子查询吧,参数绑定方式执行sql,类似这样:
sql = “select id from users where username=@un and password=@pw”;
execute(sql, un=‘root’,pw=‘root’)

这个有点像lookup了。比如:

nebula> LOOKUP ON player WHERE player.name == "Tony Parker" \
YIELD player.name, player.age;
=======================================
| VertexID | player.name | player.age |
=======================================
| 101      | Tony Parker | 36         |
---------------------------------------

文档搁这:https://docs.nebula-graph.com.cn/manual-CN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/lookup-syntax/

1.0不支持参数, 2.0将来会支持使用$param的形式调用外部参数

1赞

浙ICP备20010487号