updated test cases and added or condition
This commit is contained in:
parent
bb440a068f
commit
135b9b7202
36
queryTest.py
36
queryTest.py
@ -7,26 +7,38 @@ with open('test.json') as f:
|
||||
for element in data:
|
||||
for key, value in element.items():
|
||||
title=key
|
||||
print("Search Title: " + title)
|
||||
# print("Search Title: " + title)
|
||||
query="SELECT * FROM COMICS where "
|
||||
for i in value:
|
||||
first=True
|
||||
for j,k in i.items():
|
||||
if k != '':
|
||||
print(j,k)
|
||||
# print(j,k)
|
||||
if not first:
|
||||
query = query + "and "
|
||||
if type(k) == list:
|
||||
print(k)
|
||||
query = query + j + " in ("
|
||||
firstL = True
|
||||
for l in k:
|
||||
if not firstL:
|
||||
query = query + ","
|
||||
query = query + "'" + l + "'"
|
||||
if firstL:
|
||||
firstL = False
|
||||
query = query + ")"
|
||||
# print(k)
|
||||
if j == "series" or j == "title":
|
||||
firstS = True
|
||||
query = query + "("
|
||||
for l in k:
|
||||
if not firstS:
|
||||
query = query + "or "
|
||||
query = query + j + " like '%" + l + "%' "
|
||||
if firstS:
|
||||
firstS = False
|
||||
query = query + ") "
|
||||
else:
|
||||
query = query + j + " in ("
|
||||
firstL = True
|
||||
for l in k:
|
||||
if not firstL:
|
||||
query = query + ","
|
||||
query = query + "'" + l + "'"
|
||||
if firstL:
|
||||
firstL = False
|
||||
query = query + ") "
|
||||
|
||||
else:
|
||||
query = query + j + " like '%" + k + "%' "
|
||||
if first:
|
||||
|
Loading…
Reference in New Issue
Block a user