2017-12-18 65 views
0

我想知道是否有更简单的方法来检查数据是否在表中。目前,我不得不使用RethinkDB - Python - 检查表中是否存在数据

users = r.db("main").table("users").filter(r.row['user'] == int(msg.author.id)).run() 

for user in blacklist: 
    if users['user'] == msg.author.id: 
     return # this happens if the user sending a message was found 

我有使用这种由于用户是一个重新思考数据光标

<rethinkdb.net.DefaultCursor object at 0x0512C0B0> (done streaming): 

的响应,所以它不是像我可以用

data has item 

谢谢

+0

[rethinkdb检查是否存在记录] (https://stackoverflow.com/questions/43782915/rethinkdb-check-if-record-exists)有关吗?.. – alecxe

+0

两件事。首先是javascript,其次是基于id的文档不基于表数据。 – Doh

回答

0

解决,忘了t在python他list方法,因此所有我需要做的就是

数据=列表(r.db( “数据库”)。表( “表”)。运行())