简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM