如何使用 python 在 orientdb 查询的 where 子句中使用变量
how to use variables in where clause of orientdb query using python
代码
import pyorient
# create connection
client = pyorient.OrientDB("localhost", 2424)
# open databse
client.db_open( "testDB", "admin", "admin" )
requiredObj = client.command(" select out().question as qlist,out().seq as qseq,out().pattern as pattern,out().errormsg as errormsg from chat where app_cat='%s' and module='%s' and type='%s' and prob_cat='%s' ",(appCategory,module,type,problemCategory))
for data in requiredObj :
print data
以上方法无效请建议其他方法
你可以使用这个命令
requiredObj = client.command("select from chat where name='%s'" % "chat 1");
或
requiredObj = client.command("select from chat where name='%s' and room='%s'" % ("chat 1","1"));
希望对您有所帮助
代码
import pyorient
# create connection
client = pyorient.OrientDB("localhost", 2424)
# open databse
client.db_open( "testDB", "admin", "admin" )
requiredObj = client.command(" select out().question as qlist,out().seq as qseq,out().pattern as pattern,out().errormsg as errormsg from chat where app_cat='%s' and module='%s' and type='%s' and prob_cat='%s' ",(appCategory,module,type,problemCategory))
for data in requiredObj :
print data
以上方法无效请建议其他方法
你可以使用这个命令
requiredObj = client.command("select from chat where name='%s'" % "chat 1");
或
requiredObj = client.command("select from chat where name='%s' and room='%s'" % ("chat 1","1"));
希望对您有所帮助