I am querying a basic document in my couchbase bucket using the following query “SELECT item_id, seller_id, date, price from “+connectObj.bucket+” where date>=’”+content[‘from_time’]+"’ and date<= ‘"+ content[‘to_time’]+"’"
I am receiving the response pretty fast in 0.02 sec (0.0165578197854 sec to be exact)
the number of dcouments received is 72236
I want to work with the documents in Python.
If I transform the N1QL JSON resonse list to Python array using an iterator it takes 4-5 seconds
The processing after converting to array is again very fast somewhere 0.1 sec max (I am doing a decision tree implementation here)
I am trying to speed up the conversion process.
Few options I can work on are:
- N1QL returns me an array instead of a JSON document list
- Process JSON in Python instead of Python Array
Option 1: As per couchbase documentation, there is no attribute which I can pass while querying which will get me a response as array list instead of a list of JSON documents. (It seems PHP has that option, as told by one of my friends.) So this seems to be out of reason
If I try to import the response data in Pandas Dataframe
pandaDataFrame = json_normalize(responseData)
It is giving me error saying: ‘N1QLRequest’ object does not support indexing
If I dump response data in a JSON file
It is giving me an error saying : <couchbase.n1ql.N1QLRequest object at 0x077DEE70> is not JSON serializable
If I iteratively dump rows in python array and the feed it to Pandas Dataframe:
for responseRow in connectionBucket.n1ql_query(queryString):
pandaDataFrame = json_normalize(processData)
it works fine but 4-5 seconds to dump the data in Dataframe.
Can you help me find a way out of this?
Is there a way to process the response faster?
Can we in any way make the N1QL request JSON serializable or support indexing?
I am unable to find any documentation around it. Please help.