温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

cpy-leveldb功能怎么才能在Python 中得到实现

发布时间:2021-12-01 10:16:13 来源:亿速云 阅读:132 作者:柒染 栏目:数据库

这期内容当中小编将会给大家带来有关cpy-leveldb功能怎么才能在Python 中得到实现,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

  cpy-leveldb是在leveldb(google开源的高性能key-value数据库)的CAPI基础上开发的python绑定,目前支持leveldb的Put,Get,Delete,Write操作,以及WriteBatch的原子更新操作。下面小编来讲解下cpy-leveldb功能怎么才能在Python中得到实现?

cpy-leveldb功能怎么才能在Python中得到实现

  >>>importleveldb

  >>>db=leveldb.LevelDB("/tmp/leveldb")

  >>>db.Put("1","111")

  >>>db.Put("2","222")

  >>>db.Put("3","333")

  >>>db.Get("1")

  '111'

  >>>db.Get("3")

  '333'

  >>>db.Get("2")

  '222'

  >>>batch=leveldb.WriteBatch()

  >>>foriinxrange(20):

  ...batch.Put(str(i),"helloworld%i"%i)

  ...

  cpy-leveldb功能怎么才能在Python中得到实现

  >>>db.Get("2")

  '222'

  >>>db.Get("5")

  ''

  >>>db.Write(batch)

  >>>db.Get("5")

  'helloworld5'

  >>>db.Get("2")

  'helloworld2'

  >>>iter=leveldb.Iterator(db)

  Iterator_initexecuted.

  >>>iter.First()

  >>>iter.Key()

  '0'

  >>>iter.Value()

  'helloworld0'

  >>>iter.Last()

  >>>iter.Key()

  '9'

  >>>iter.Value()

  'helloworld9'

  >>>iter.First()

  >>>iter.Next()

  >>>iter.Key()

  '1'

  >>>iter.Next()

  >>>iter.Key()

  '10'

  >>>iter.Next()

  >>>iter.Key()

  '11'

  >>>iter.Value()

  'helloworld11'

上述就是小编为大家分享的cpy-leveldb功能怎么才能在Python 中得到实现了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI