Skip to content

Instantly share code, notes, and snippets.

@hashware
Created June 21, 2018 14:23
Show Gist options
  • Save hashware/69b56429c48a39d962fa816a03b513f4 to your computer and use it in GitHub Desktop.
Save hashware/69b56429c48a39d962fa816a03b513f4 to your computer and use it in GitHub Desktop.

eos的块数据导入MongoDB后
进行查询操作

比如查询所有包含buyrambytes动作的块

#!/usr/bin/env python3
# coding:utf-8

from pymongo import MongoClient

conn = MongoClient('127.0.0.1', 27017)
db = conn.eosdb
eosset = db.eosset

q = eosset.find({"transactions":
                     {"$elemMatch":
                         {"trx.transaction.actions":
                              {"$elemMatch":
                                   {"name":"buyrambytes"}
                              }
                         }
                     }
                })

print("len(q)", q.count())
for x in q:
    print(x['block_num'])
    break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment