curl -XGET http://localhost/api/raw/backup/testtable?filter=id,eq,5
import requests,json
#// Set Up Query
#// Any `subkey` array that is empty will mean that the field is not stored with a JSONB type
payload = {"query": {
"or_": [
{"column":"data","subkeys":["sale"],"op":"gt","value":1732},
{"column":"data","subkeys":["category"],"op":"eq","value":"win32_computersystemA"},
{"column":"data","subkeys":["category"],"op":"eq","value":"win32_computersystemB"},
],
"must_":[
{"column":"data","subkeys":["category"],"op":"eq","value":"win32_computersystemA"},
{"column":"id","subkeys":[],"op":"eq","value":172}, #// Not searching JSONB field (subkeys empty)
],
"not_": [
{"column":"data","subkeys":["category"],"op":"ilike","value":"win32_computersystemcoB"},
{"column":"data","subkeys":["category"],"op":"ilike","value":"win32_computersystem"},
{"column":"data","subkeys":["sale"],"op":"gt","value":17},
{"column":"data","subkeys":["category"],"op":"eq","value":"win32_computersystem"},
]
}
}
#// Send request to the server
r = requests.get("http://localhost/api/raw/backup/testtable",json=payload)
data=r.json()
#// Print out the data
print json.dumps(data,indent=4)
'''
.Description: Helper function to generate queries in sqlalchemy
.Example:
query = DynamicQuery(
model_class="Users", --> databaseClass (M)
request_args=[], --> parse request.args for parameters (from a uri string)
filter=[("id", 'eq', 1),("datatype", 'eq', "path"),("date_added","gt","2018-05-10 02:05:57.1913")], --> filter to apply
groupby=[("datatype","count"),("datavalue","group")], --> groupby fields
orderby=("id","desc"),
getfirst=False, --> return the first record, a lot faster than sorting and limiting on large datasets
getcount=False, --> return the count record
as_query=False, --> return the raw query
as_object=False, --> return the results as an object
as_datatables=False, --> return the results in datatables form
as_chartjs=False, --> return the results in chartjs form (requires groupby parameter)
as_json=False, --> return the results as JSON
as_schema=False, --> return the schema of a table
crud=action, --> perform CRUD ops
data=data, --> data to be used for CRUD (dictionary required, collect with: "data=request.get_json(silent=True)" )
qjson=data, --> send a query formatted as json (dictionary required, collect with: "qjson=request.get_json(silent=True)" ) # BETA
inc_fields=["username","id"], --> fields to include in the response
exc_fields=["password"], --> fields to exclude in the response
limit=5 --> limit the results
)
query.generate().all()
'''