简体   繁体   English

如何使用python在orientdb查询的where子句中使用变量

[英]how to use variables in where clause of orientdb query using python

code代码

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

the above one is not working please suggest alternative way上面的一个不起作用请建议替代方法

You could use this command你可以使用这个命令

requiredObj = client.command("select from chat where name='%s'" % "chat 1");

or或者

requiredObj = client.command("select from chat where name='%s' and room='%s'" % ("chat 1","1"));

Hope it helps希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用“ where in”子句 - how to use “where in” clause 在where子句中使用字符串比较的Python MySQL查询 - Python MySQL query using string comparison in where clause python 通过使用全局变量的 where 子句从 bigquery 查询数据 - python query data from bigquery with where clause using a global variable 如何使用python驱动程序在Cassandra的where子句中将日期时间用作群集? - How to use date time as a cluster in where clause in Cassandra using python driver? 如何在where IN子句中替换python sql查询中的参数INT值? - How to substitute parameter INT value in python sql query in where IN clause? 如何在 SQL Where IN 子句中使用 Python 列表? - How can I use a Python List in a SQL Where IN Clause? 如何在python和CosmoDB中的WHERE子句中使用列表作为参数 - How to use a list as parameter in clause WHERE in python and CosmoDB 如何在python中的where子句中使用变量访问sql - How to use a variable in where clause in python to access sql Postres/Python - 使用一个大查询还是几个较小的查询更好? 您如何决定要包含在“WHERE IN”子句中的项目数量? - Postres/Python - is it better to use one large query, or several smaller ones? How do you decide number of items to include in 'WHERE IN' clause? 如何在 Python SQL 查询中使用变量? - How to use variables in Python SQL query?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM