Listing RethinkDB request response in a reasonable way

I am in the Yelp Dataset Challenge and I am using RethinkDB to store JSON documents for each of the different datasets.

I have the following script:

import rethinkdb as r
import json, os

RDB_HOST =  os.environ.get('RDB_HOST') or 'localhost'
RDB_PORT = os.environ.get('RDB_PORT') or 28015
DB = 'test'

connection = r.connect(host=RDB_HOST, port=RDB_PORT, db=DB)

query = r.table('yelp_user').filter({"name":"Arthur"}).run(connection)
print(query)

      

But when I run it on the terminal in virtualenv I get this as an example response:

<rethinkdb.net.DefaultCursor object at 0x102c22250> (streaming):
[{'yelping_since': '2014-03', 'votes': {'cool': 1, 'useful': 2, 'funny': 1}, 'review_count': 5, 'id': '08eb0b0d-2633-4ec4-93fe-817a496d4b52', 'user_id': 'ZuDUSyT4bE6sx-1MzYd2Kg', 'compliments': {}, 'friends': [], 'average_stars': 5, 'type': 'user', 'elite': [], 'name': 'Arthur', 'fans': 0}, ...]

      

I know I can use pprint for pretty printable outputs, but the big problem I don't understand how to solve is just printing them in an intelligent way, like not just showing "..." as the end of the output.

Any suggestions?

+3


source to share


1 answer


run

returns an iterable cursor. Let's go to it to get all the lines:



query = r.table('yelp_user').filter({"name":"Arthur"})
for row in query.run(connection):
    print(row)

      

+3


source







All Articles