使用python计数lmdb数据库中的记录数 [英] Count number of records in lmdb databse with python

查看:283
本文介绍了使用python计数lmdb数据库中的记录数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码打开lmdb数据库:

I open a lmdb database using this code:

    lmdb_env = lmdb.open(source_path, readonly=True)

如何计算该数据库中的记录数?

How can I count the number of records in this database?

推荐答案

我找到了使用for循环的简单解决方案.在这里:

I found a simple solution using for loop. Here it is:

count = 0
for key, value in lmdb_env.cursor():
        count = count + 1  

但是,我认为应该使用更好的预定义功能.

However, I think there should be a better way using pre-defined function.

这篇关于使用python计数lmdb数据库中的记录数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆