As added information (bonus points for actually helping me solve the problem):
I have a test database where my Python client sits on the Twitter sample endpoint and catches tweets. This works great and I am very happy with the results.
Now I want to write a second script to trim the database. (The sample endpoint produces about 12 GB/day.)
I have a view that emits documents using numeric key of a tweet’s creation time, e.g. 1174932714. The following URL from the CB view editor web page works great:
http://127.0.0.1:8092/twitter/_design/statuses/_view/by_date?connection_timeout=60000&limit=10&skip=0
resulting in:
{"total_rows":5847613,"rows":[
{"id":"st:13110261","key":1174932714,"value":null},
{"id":"st:24656161","key":1176299350,"value":null},
{"id":"st:193253582","key":1186546652,"value":null},
{"id":"st:243086362","key":1188766579,"value":null},
{"id":"st:767116463","key":1204735210,"value":null},
{"id":"st:790555585","key":1208374803,"value":null},
{"id":"st:823173396","key":1212135874,"value":null},
{"id":"st:837724080","key":1213791679,"value":null},
{"id":"st:844266941","key":1214499099,"value":null},
{"id":"st:906070011","key":1220300170,"value":null}
]
}
That is what I expected and desired.
The below script should do the same thing:
import sys, time, calendar
from couchbase import Couchbase
from couchbase.exceptions import *
from couchbase.views.params import *
cb = Couchbase.connect(bucket=‘twitter’)
def main(args=sys.argv[1:]):
q = Query
q.limit = 10
q.stale = STALE_UPDATE_BEFORE
results = cb.query("statuses", "by_date", use_devmode=False, query=q)
print(results)
print(results.errors)
main()
Instead it prints:
View<Design=statuses, View=by_date, Query=, Rows Fetched=0>
[]
No errors are generated but no rows are fetched either.
Why? No clue. The REST API works but the Python client (v1.0.0-beta on C v2.0.6) doesn’t. As this is a pretty simple query, I doubt this is a version issue.
Is the Python client generating the same request as the view console? Don’t know. A log would be nice. BTW, the connect document does not claim to have any errors in picking up the server. When the query is put into the script sitting on the endpoint, the same result ensues.
Anon,
Andrew