for

ReQL command: for

Command syntax

for items in cursor:
for items in array:
for items in feed:

Description

Lazily iterate over a result set one element at a time.

RethinkDB sequences can be iterated through via the Python Iterable interface; use standard Python commands like for loops to access each item in the sequence.

Example: Let’s process all the elements!

cursor = r.table('users').run(conn)
for doc in cursor:
    process_row(doc)

Example: Stop the iteration prematurely and close the connection manually.

cursor = r.table('users').run(conn)
for doc in cursor:
    ok = process_row(doc)
    if ok is False:
        cursor.close()
        break

Related commands

Get more help

Couldn't find what you were looking for?

© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/python/each/

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部