wbolster / plyvel

Plyvel, a fast and feature-rich Python interface to LevelDB
https://plyvel.readthedocs.io/
Other
531 stars 76 forks source link

How can open the leveldb file with plyvel? #161

Closed hwypengsir closed 5 months ago

hwypengsir commented 6 months ago

Check 000005.ldb with file command:

file /home/debian/.config/ibus/rime/luna_pinyin.userdb/000005.ldb
/home/debian/.config/ibus/rime/luna_pinyin.userdb/000005.ldb: LevelDB table data

xxd and vim can open it,it is not empty.I want to read it with plyvel:

import plyvel
dbfile = "/home/debian/.config/ibus/rime/luna_pinyin.userdb/000005.ldb"
db = plyvel.DB(dbfile)

The error info:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "plyvel/_plyvel.pyx", line 247, in plyvel._plyvel.DB.__init__
  File "plyvel/_plyvel.pyx", line 88, in plyvel._plyvel.raise_for_status
plyvel._plyvel.IOError: b'IO error: /home/debian/.config/ibus/rime/luna_pinyin.userdb/000005.ldb/LOCK: Not a directory'

how can read it then?

wbolster commented 5 months ago

open the directory containing that file, not the file itself. leveldb databases are directories.

wbolster commented 5 months ago

(also this is literally what the error message said)